Skip to content

Commit 43bf8b3

Browse files
[3.14] gh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP servers (GH-135405) (GH-135538)
(cherry picked from commit 2bd3895)
1 parent e89c7f1 commit 43bf8b3

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

Lib/http/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
class HTTPServer(socketserver.TCPServer):
138138

139139
allow_reuse_address = True # Seems to make sense in testing environment
140-
allow_reuse_port = True
140+
allow_reuse_port = False
141141

142142
def server_bind(self):
143143
"""Override server_bind to store the server name."""

Lib/logging/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ class ConfigSocketReceiver(ThreadingTCPServer):
10181018
"""
10191019

10201020
allow_reuse_address = True
1021-
allow_reuse_port = True
1021+
allow_reuse_port = False
10221022

10231023
def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT,
10241024
handler=None, ready=None, verify=None):

Lib/test/test_logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ class TestTCPServer(ControlMixin, ThreadingTCPServer):
10361036
"""
10371037

10381038
allow_reuse_address = True
1039-
allow_reuse_port = True
1039+
allow_reuse_port = False
10401040

10411041
def __init__(self, addr, handler, poll_interval=0.5,
10421042
bind_and_activate=True):

Lib/xmlrpc/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer,
578578
"""
579579

580580
allow_reuse_address = True
581-
allow_reuse_port = True
581+
allow_reuse_port = False
582582

583583
# Warning: this is for debugging purposes only! Never set this to True in
584584
# production code, as will be sending out sensitive information (exception
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Set the ``allow_reuse_port`` class variable to ``False`` on the XMLRPC,
2+
logging, and HTTP servers. This matches the behavior in prior Python
3+
releases, which is to not allow port reuse.

0 commit comments

Comments
 (0)