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: Shutdown may lose an active connection #33313
Comments
I have encountered the same problem. Parts of the codes in server.Serve:
With the codes here, you will be able reproduce the problem. |
As this issue pointed out:
It seems that they don't think this problem as a bug. Maybe we should set the shutdown flag before we call Shutdown method, and just return an error if a request is received after the server shutdown. |
This does not look like a duplicate of #31438. Here the connection has not reached the handler yet. This looks like it might be a bug. |
@FiloSottile, @andybons, if this is a bug report about Go 1.12, how is this a release blocker for Go 1.14? |
Hm. I didn’t notice that. Will remove |
Change https://golang.org/cl/213442 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes go 1.12
What operating system and processor architecture are you using (
go env
)?go env
Outputmy english is not very good. I try to describe it.
i found a problem in http shutdown(), when the shutdown function is executed, srv.mu.Lock() is executed. but at this time the net accept function can still be executed normally, execute c.setState(c.rwc, StateNew) put a new connection into activeConn and wait for srv.mu.Unlock().
when shutdown() finishes processing all activeConn connections, it will execute srv.mu.Unlock() and end the shutdown function, c.setState() gets the lock and puts a new connection into activeConn. At this point, there will still be an active connection after the shutdown() is completed.
The text was updated successfully, but these errors were encountered: