diff options
author | Charles-Fran?ois Natali <cf.natali@gmail.com> | 2014-10-13 19:28:50 +0100 |
---|---|---|
committer | Charles-Fran?ois Natali <cf.natali@gmail.com> | 2014-10-13 19:28:50 +0100 |
commit | 5ae40b49d60fc46b2eb6967d3a557480a9a28edc (patch) | |
tree | bc2821e61077bd30a68b26448300ad25e15e00d6 /Lib/socketserver.py | |
parent | 826b9a9b44c797aa39eb87fb306a212c93deed22 (diff) | |
parent | afae2df730da719c8940192cdd32615c32b72bdf (diff) | |
download | cpython-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.py | 8 |
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. |