mirror of https://github.com/gorilla/websocket.git
Do not handle network error in SetCloseHandler()
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.
This commit is contained in:
parent
0f0acefeac
commit
9a2140519a
8
conn.go
8
conn.go
|
@ -1159,8 +1159,12 @@ func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
|
|||
h = func(code int, text string) error {
|
||||
message := FormatCloseMessage(code, "")
|
||||
err := c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
|
||||
if err != nil && err != ErrCloseSent {
|
||||
return err
|
||||
if err != nil {
|
||||
if _, ok := err.(net.Error); ok {
|
||||
return nil
|
||||
} else if err != ErrCloseSent {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue