Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/websocket: websocket.Conn.Close leaks file descriptors if remote has disconnected #10866

Closed
davecheney opened this issue May 15, 2015 · 1 comment
Assignees
Milestone

Comments

@davecheney
Copy link
Contributor

@davecheney davecheney commented May 15, 2015

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".

/cc @bradfitz

@davecheney davecheney self-assigned this May 18, 2015
@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Jun 3, 2015
@mikioh
Copy link
Contributor

@mikioh mikioh commented Jul 30, 2015

Closed by golang/net@bb64f4d.

@mikioh mikioh closed this Jul 30, 2015
@golang golang locked and limited conversation to collaborators Aug 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.