Issue #8184: multiprocessing: On Windows, don't set SO_REUSEADDR on C… · pythoncapi/cpython@ed4a8fc · GitHub
Skip to content

Commit ed4a8fc

Browse files
author
Charles-François Natali
committed
Issue python#8184: multiprocessing: On Windows, don't set SO_REUSEADDR on Connection
sockets, and set FILE_FLAG_FIRST_PIPE_INSTANCE on named pipes, to make sure two listeners can't bind to the same socket/pipe (or any existing socket/pipe).
1 parent 1aa54a4 commit ed4a8fc

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

Lib/multiprocessing/connection.py

Lines changed: 8 additions & 3 deletions

Lib/test/test_multiprocessing.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,17 @@ def test_missing_fd_transfer(self):
17791779
self.assertRaises(RuntimeError, reduction.recv_handle, conn)
17801780
p.join()
17811781

1782+
class _TestListener(BaseTestCase):
1783+
1784+
ALLOWED_TYPES = ('processes')
1785+
1786+
def test_multiple_bind(self):
1787+
for family in self.connection.families:
1788+
l = self.connection.Listener(family=family)
1789+
self.addCleanup(l.close)
1790+
self.assertRaises(OSError, self.connection.Listener,
1791+
l.address, family)
1792+
17821793
class _TestListenerClient(BaseTestCase):
17831794

17841795
ALLOWED_TYPES = ('processes', 'threads')
@@ -1799,6 +1810,7 @@ def test_listener_client(self):
17991810
self.assertEqual(conn.recv(), 'hello')
18001811
p.join()
18011812
l.close()
1813+
18021814
#
18031815
# Test of sending connection and socket objects between processes
18041816
#

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ Library
472472

473473
- Issue #13846: Add time.monotonic(), monotonic clock.
474474

475+
- Issue #8184: multiprocessing: On Windows, don't set SO_REUSEADDR on
476+
Connection sockets, and set FILE_FLAG_FIRST_PIPE_INSTANCE on named pipes, to
477+
make sure two listeners can't bind to the same socket/pipe (or any existing
478+
socket/pipe).
479+
475480
- Issue #10811: Fix recursive usage of cursors. Instead of crashing,
476481
raise a ProgrammingError now.
477482

Modules/_multiprocessing/win32_functions.c

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)