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: connection leak on panic #4050
Labels
Milestone
Comments
Owner changed to @bradfitz. Status changed to Accepted. |
Reading the source code for server.go, it seems reasonable to c.Close() in the defer and remove c.Close() from the bottom of the function. I suppose you could also just call c.Close() in the deferred function and at the bottom of serve. The implementations seem safe to close twice. Does one of these solutions sounds reasonable? I can go ahead and code it up. |
I think it's worth fixing this ASAP. panic(nil) anywhere here (and particularly in unpredictable user code) is silently discarded, and leaks connections. Of course, panics being primarily used for exceptional cases means this doesn't happen often enough to be noticeable for some time, which is even worse. I'm not sure why c, and c.rwc are closed separately, and didn't bother to dig into it. I think the easiest solution is to stuff: defer func() { if !c.hijacked { c.close() } }() At line 617, and remove c.close() from line 704. |
https://golang.org/cl/6971049 Status changed to Started. |
This issue was closed by revision 91934ff. Status changed to Fixed. |
anacrolix
added
fixed
Suggested
Issues that may be good for new contributors looking for work to do.
labels
Dec 19, 2012
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
The text was updated successfully, but these errors were encountered: