diff options
author | Charles-François Natali <cf.natali@gmail.com> | 2014-10-13 19:19:26 +0100 |
---|---|---|
committer | Charles-François Natali <cf.natali@gmail.com> | 2014-10-13 19:19:26 +0100 |
commit | 0f4f048fa5ff06438a4624bc1dc02aa458a79748 (patch) | |
tree | 26aa0625a57f2e7d49c3c93a9a7c30d3b9d4f631 /Lib/socketserver.py | |
parent | efc7258377e79cff0ea41f97fa999873325e2fb5 (diff) | |
download | cpython-git-0f4f048fa5ff06438a4624bc1dc02aa458a79748.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 2f395fac24..73399115b6 100644 --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -426,8 +426,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. |