You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the current Conn.Close behaviour can leak file descriptors if the server has gone away before the client calls .Close
// Close implements the io.Closer interface.
func (ws *Conn) Close() error {
err := ws.frameHandler.WriteClose(ws.defaultCloseStatus)
if err != nil {
return err
}
return ws.rwc.Close()
}
In the case that the remote side has closed the connection, WriteClose will return an error which will be returned to the caller without calling ws.rwc.Close. As it is customary to ignore the error from an io.Closer.Close, and even when not, the error is treated as opaque there is no indication that Close didn't actually release the file descriptor associated with ws.rwc. Even if the error was handled from the caller of Close, it would typically be io.EOF or some operating system specific version of "connection closed unexpectedly".
In the current Conn.Close behaviour can leak file descriptors if the server has gone away before the client calls .Close
In the case that the remote side has closed the connection, WriteClose will return an error which will be returned to the caller without calling
ws.rwc.Close
. As it is customary to ignore the error from anio.Closer.Close
, and even when not, the error is treated as opaque there is no indication that Close didn't actually release the file descriptor associated withws.rwc
. Even if the error was handled from the caller of Close, it would typically beio.EOF
or some operating system specific version of "connection closed unexpectedly"./cc @bradfitz
The text was updated successfully, but these errors were encountered: