diff options
author | Charles-François Natali <cf.natali@gmail.com> | 2014-10-13 18:28:50 (GMT) |
---|---|---|
committer | Charles-François Natali <cf.natali@gmail.com> | 2014-10-13 18:28:50 (GMT) |
commit | acbf5235b869ce155b34e2767960d55265f0c261 (patch) | |
tree | 8e943bf8b0fd0e8e375dbb1f977c0bfde4694716 /Lib/test/test_socketserver.py | |
parent | dfbeb160de829d16d3668dec5bc902a31ad25835 (diff) | |
parent | 0f4f048fa5ff06438a4624bc1dc02aa458a79748 (diff) | |
download | cpython-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/test/test_socketserver.py')
-rw-r--r-- | Lib/test/test_socketserver.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index 8e0fde4..f5d8d52 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -270,6 +270,16 @@ class SocketServerTest(unittest.TestCase): t.join() s.server_close() + def test_tcpserver_bind_leak(self): + # Issue #22435: the server socket wouldn't be closed if bind()/listen() + # failed. + # Create many servers for which bind() will fail, to see if this result + # in FD exhaustion. + for i in range(1024): + with self.assertRaises(OverflowError): + socketserver.TCPServer((HOST, -1), + socketserver.StreamRequestHandler) + def test_main(): if imp.lock_held(): |