[Python-checkins] cpython: Issue #19182: Fixed socket leak on exception when connecting.

vinay.sajip python-checkins at python.org
Sun Oct 6 19:36:11 CEST 2013


http://hg.python.org/cpython/rev/bd314db5532d
changeset:   86133:bd314db5532d
parent:      86131:aeb7a5b3e617
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Sun Oct 06 18:36:00 2013 +0100
summary:
  Issue #19182: Fixed socket leak on exception when connecting.

files:
  Lib/logging/handlers.py |  6 +++++-
  1 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -518,7 +518,11 @@
         else:
             result = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
             result.settimeout(timeout)
-            result.connect(self.address)
+            try:
+                result.connect(self.address)
+            except OSError:
+                result.close()  # Issue 19182
+                raise
         return result
 
     def createSocket(self):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list