summaryrefslogtreecommitdiff
path: root/Lib/socketserver.py
diff options
context:
space:
mode:
authorCharles-Fran?ois Natali <cf.natali@gmail.com>2014-10-13 19:28:50 +0100
committerCharles-Fran?ois Natali <cf.natali@gmail.com>2014-10-13 19:28:50 +0100
commit5ae40b49d60fc46b2eb6967d3a557480a9a28edc (patch)
treebc2821e61077bd30a68b26448300ad25e15e00d6 /Lib/socketserver.py
parent826b9a9b44c797aa39eb87fb306a212c93deed22 (diff)
parentafae2df730da719c8940192cdd32615c32b72bdf (diff)
downloadcpython-5ae40b49d60fc46b2eb6967d3a557480a9a28edc.tar.gz
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 3d58590d27..f1b0e4a620 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.