summaryrefslogtreecommitdiffstats
path: root/Lib/socketserver.py
diff options
context:
space:
mode:
authorCharles-François Natali <cf.natali@gmail.com>2014-10-13 18:28:50 (GMT)
committerCharles-François Natali <cf.natali@gmail.com>2014-10-13 18:28:50 (GMT)
commitacbf5235b869ce155b34e2767960d55265f0c261 (patch)
tree8e943bf8b0fd0e8e375dbb1f977c0bfde4694716 /Lib/socketserver.py
parentdfbeb160de829d16d3668dec5bc902a31ad25835 (diff)
parent0f4f048fa5ff06438a4624bc1dc02aa458a79748 (diff)
downloadcpython-acbf5235b869ce155b34e2767960d55265f0c261.zip
cpython-acbf5235b869ce155b34e2767960d55265f0c261.tar.gz
cpython-acbf5235b869ce155b34e2767960d55265f0c261.tar.bz2
Issue #22435: Fix a file descriptor leak when SocketServer bind fails.
Diffstat (limited to 'Lib/socketserver.py')
-rw-r--r--Lib/socketserver.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/socketserver.py b/Lib/socketserver.py
index 3d58590..f1b0e4a 100644
--- a/Lib/socketserver.py
+++ b/Lib/socketserver.py
@@ -439,8 +439,12 @@ class TCPServer(BaseServer):
self.socket = socket.socket(self.address_family,
self.socket_type)
if bind_and_activate:
- self.server_bind()
- self.server_activate()
+ try:
+ self.server_bind()
+ self.server_activate()
+ except:
+ self.server_close()
+ raise
def server_bind(self):
"""Called by constructor to bind the socket.