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

net: document errata on SetLinger of TCPConn #7974

Closed
mikioh opened this issue May 12, 2014 · 3 comments
Closed

net: document errata on SetLinger of TCPConn #7974

mikioh opened this issue May 12, 2014 · 3 comments

Comments

@mikioh
Copy link
Contributor

mikioh commented May 12, 2014

The linger option to TCPConn doesn't work as we expect especially "If sec > 0,
Close blocks for at most sec seconds waiting for data to be sent and acknowledged."
part because current  TCPConn.Close implementation never blocks anything instead of
retuning syscall.EWOULDBLOCK or similar.

func (fd *netFD) Close() error {
        (snip)
        // Unblock any I/O.  Once it all unblocks and returns,
        // so that it cannot be referring to fd.sysfd anymore,
        // the final decref will close fd.sysfd.  This should happen
        // fairly quickly, since all the I/O is non-blocking, and any
        // attempts to block in the pollDesc will return errClosing.
}

Other matters to be attended to;

- A conventional issue on TCP socket closing w/ lingering. When we call TCPConn.Close to
SetLinger(0) configured sockets on active-close side, TCPConn.Read on passive-close side
returns syscall.ECONNRESET or similar instead of io.EOF because lingering usually causes
sending RSTs. It really depends on underlying protocol stack implementation, though.

- Another conventional issue on TCP socket closing w/ lingering. SetLinger(sec > 0)
usually causes 2MSL close wait, SetLinger(sec > 0) configured sockets remain inside
the kernel for a short time (2MSL).

Perhaps we should encourage people not to use SetLinger and recommend to use CloseRead,
CloseWrite instead.
@gopherbot
Copy link

Comment 1:

CL https://golang.org/cl/95320043 mentions this issue.

@mikioh
Copy link
Contributor Author

mikioh commented May 14, 2014

Comment 2:

This issue was closed by revision d145f0f.

Status changed to Fixed.

@mikioh
Copy link
Contributor Author

mikioh commented May 23, 2014

Comment 3:

Issue #7979 has been merged into this issue.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants