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/http: Server.Close may not able to close all connections #48642

Open
shinny-chengzhi opened this issue Sep 27, 2021 · 2 comments · May be fixed by #48753
Open

net/http: Server.Close may not able to close all connections #48642

shinny-chengzhi opened this issue Sep 27, 2021 · 2 comments · May be fixed by #48753

Comments

@shinny-chengzhi
Copy link

@shinny-chengzhi shinny-chengzhi commented Sep 27, 2021

I encountered lingering connection after calling Server.Close and it's not closed by Server.Close

Here is reproducible example: https://play.golang.org/p/9aLVDwWPQhH

The problem is http/server.go: Server.Serve function didn't check if Server is already closed before calling handler, and if Server.Close been called after l.Accept return but before c.setState(c.rwc, StateNew, runHooks), the new connection is not registered in the activeConn map when Server.Close try to close all connections.

The example code simulate this condition by sleep one second during ConnContext call. Program can exit corrected if this sleep is removed.

AlexanderYastrebov added a commit to AlexanderYastrebov/go that referenced this issue Oct 3, 2021
@AlexanderYastrebov AlexanderYastrebov linked a pull request that will close this issue Oct 3, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 3, 2021

Change https://golang.org/cl/353714 mentions this issue: net/http: close accepted connection

@mknyszek mknyszek added this to the Backlog milestone Oct 4, 2021
@mknyszek
Copy link
Contributor

@mknyszek mknyszek commented Oct 4, 2021

CC @neild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants