Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net: Listener sometimes accepts connections after Close #13762
I've written a repro test here:
It basically does the following:
On the listener side, I expect to receive at most
This works as expected on OSX, but on Linux, it seems to receive a successful connection after the listener has been closed.
Some things I noticed:
I would expect that a Listener will not accept any further socket attempts after
When Close is called on the listener, the goroutine blocked on Accept does not immediately error out. It's possible that new incoming connections will be accepted (at least on Linux). See: golang/go#13762 We can avoid this by making sure that the server is really closed (e.g. not accepting new connections) in close_test before trying to make a call.
@mikioh I saw #10527, but I think this is a little different. #10527 is basically that the socket isn't closed since
In this case,
To conclude, this is a duplicate of #10527. In general this may happen when the shared fdMutex in TCPListener is taken by acceptor goroutine prior to TCPListener.Close like the following:
See #10527 for further information.
@mikioh Ah, I thought that perhaps Accept would check whether the socket was marked as Closed but that doesn't affect epoll from accepting new connections.
It looks like the other issue has not had any progress since it was last marked as possibly for go 1.5. Can #10527 be prioritized for go 1.7? Thanks