Skip to content

Commit

Permalink
Do not handle network error in SetCloseHandler()
Browse files Browse the repository at this point in the history
The 666c197 added an error handling in `SetCloseHandler()` and peer
stops getting `CloseError` when network issue like `write: broken
pipe` happens because the close handle returns the error.

Hence this patch changes to skip network error handling.
  • Loading branch information
nak3 committed Nov 8, 2023
1 parent ac0789b commit 119d436
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,9 @@ func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
h = func(code int, text string) error {
message := FormatCloseMessage(code, "")
if err := c.WriteControl(CloseMessage, message, time.Now().Add(writeWait)); err != nil {
if _, ok := err.(net.Error); ok {
return nil
}
return err
}
return nil
Expand Down

0 comments on commit 119d436

Please sign in to comment.