classification
Title: Socket leak if HTTPConnection.getresponse() fails
Type: resource usage Stage: resolved
Components: Library (Lib) Versions: Python 3.5, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: martin.panter, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2014-03-23 04:05 by martin.panter, last changed 2014-12-01 11:24 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
test.patch martin.panter, 2014-03-23 04:05 review
close.patch martin.panter, 2014-03-23 04:06
Messages (7)
msg214546 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-03-23 04:05
Here is a regression test and patch to close the socket reader when a HTTP server causes getresponse() to fail, for instance if the server times out and drops the connection without sending any response. Without the patch the socket will only be closed by the garbage collector at some arbitrary point.
msg231330 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-11-18 17:21
Could you please submit a contributor form (https://www.python.org/psf/contrib/) Martin?
msg231917 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-12-01 09:15
What is the status of your contributor agreement Martin?
msg231922 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-12-01 09:37
Hi Serhiy, I submitted the form online on 22 Nov; just patiently waiting for it to come through now.

In the last few minutes I noticed an asterisk has appeared against my name on the bug tracker, so hopefully it is all good now.
msg231923 - (view) Author: Roundup Robot (python-dev) Date: 2014-12-01 09:52
New changeset 561d1d0de518 by Serhiy Storchaka in branch 'default':
Issue #21032: Deprecated the use of re.LOCALE flag with str patterns or
https://hg.python.org/cpython/rev/561d1d0de518
msg231930 - (view) Author: Roundup Robot (python-dev) Date: 2014-12-01 11:16
New changeset f88c00391dd8 by Serhiy Storchaka in branch '2.7':
Issue #21032. Fixed socket leak if HTTPConnection.getresponse() fails.
https://hg.python.org/cpython/rev/f88c00391dd8

New changeset ba72da4883eb by Serhiy Storchaka in branch '3.4':
Issue #21032. Fixed socket leak if HTTPConnection.getresponse() fails.
https://hg.python.org/cpython/rev/ba72da4883eb

New changeset 62a058c76869 by Serhiy Storchaka in branch 'default':
Issue #21032. Fixed socket leak if HTTPConnection.getresponse() fails.
https://hg.python.org/cpython/rev/62a058c76869
msg231934 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-12-01 11:24
Few notes about patches. Check patches for trailing spaces. And it would be more suitable if you provide single patch instead of a couple of patches. I have slightly changed the test, so it checks that the file is actually closed, not lost, The fix LGTM.

Thank you for your contribution Martin.
History
Date User Action Args
2014-12-01 11:24:01serhiy.storchakasetstatus: open -> closed
versions: + Python 2.7
messages: + msg231934

resolution: fixed
stage: patch review -> resolved
2014-12-01 11:16:43python-devsetmessages: + msg231930
2014-12-01 09:52:11python-devsetnosy: + python-dev
messages: + msg231923
2014-12-01 09:37:34martin.pantersetmessages: + msg231922
2014-12-01 09:15:24serhiy.storchakasetmessages: + msg231917
2014-11-18 17:21:19serhiy.storchakasetversions: + Python 3.5
nosy: + serhiy.storchaka

messages: + msg231330

assignee: serhiy.storchaka
stage: patch review
2014-03-23 04:06:13martin.pantersetfiles: + close.patch
2014-03-23 04:05:47martin.pantercreate