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.Listener.Close() doesn't close the listener until another connection is accepted #1375

Closed
hoisie opened this issue Dec 29, 2010 · 3 comments

Comments

@hoisie
Copy link
Contributor

hoisie commented Dec 29, 2010

Attached is a file that demonstrates this issue. To run it, just run;
6g closebug2.go && 6l closebug2.6 && ./6.out

This starts a server (listener.Accept() in a loop), and then closes the listener after
one second. However, it
still accepts one more connection (you can see this by running telnet localhost 9999).
Only after that connection is processed is the listener closed. 

What steps will reproduce the problem?
1. Call listener.Accept in a loop (this blocks)
2. On a separate goroutine, call listener.Close()
3. the listener will not close until another connection is accepted

What is the expected output?
The listener will close immediately

What do you see instead?
The listener waits until another connection has been accepted, then closes


Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
osx

Which revision are you using?  (hg identify)
51c777dbccb9+ release/release.2010-12-22

Please provide any additional information below.
The problem seems to be in net/fd.go

Both fd.Close() and fd.Accept() call fd.incref(), which acquires a lock. It seems that
the lock is held by Accept(), and only when it is released is Close() called. 

Should there be a special condition that handles this?
@rsc
Copy link
Contributor

rsc commented Jan 4, 2011

Comment 1:

This issue was closed by revision ed1cbca.

Status changed to Fixed.

@rsc
Copy link
Contributor

rsc commented Jan 19, 2011

Comment 2:

Issue #1058 has been merged into this issue.

@rsc
Copy link
Contributor

rsc commented Jan 19, 2011

Comment 3:

Issue #1059 has been merged into this issue.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
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

3 participants