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
x/net/context/ctxhttp: race condition preventing response from being closed #14065
Labels
Milestone
Comments
Which version of Go? ctxhttp operated differently depending on the Go version. |
Never mind, I see the problem. |
I seem to recall seeing some workaround code for <=1.4. @jacobsa ? |
Dupe of #13293. |
I'm not sure it is. |
CL https://golang.org/cl/18802 mentions this issue. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The
ctxhttp.Do
method contains a race condition when the context is cancelled before theclient.Do
performed in a go routine returns. Thehttp.Response
is discarded, leaving itsBody
opened and thus leading to sockets left inCLOSE_WAIT
state.To reproduce the issue, run this on Linux (can't reproduce on osx, I'm not sure why):
The output is:
As the
res
isnil
, I have no way for the caller to close theresp.Body
.Then look at
netstat -lan | grep CLOSE_WAIT
, you will see a new socket lying down forever.The text was updated successfully, but these errors were encountered: