mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #22435: Fix a file descriptor leak when SocketServer bind fails.
This commit is contained in:
parent
efc7258377
commit
0f4f048fa5
3 changed files with 18 additions and 2 deletions
|
|
@ -302,6 +302,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():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue