gh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP server… · python/cpython@2bd3895 · GitHub
Skip to content

Commit 2bd3895

Browse files
authored
gh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP servers (GH-135405)
Prior to issue #120485 these servers did not allow port reuse, which makes sense as the behavior of port reuse is surprising if you're not expecting it. It's unclear to me why these services were switched to allow port reuse, but I believe the desired behavior (unless subclasses opt in) is to not allow port reuse. See also: https://bugzilla.redhat.com/show_bug.cgi?id=2323170
1 parent 8979d3a commit 2bd3895

5 files changed

Lines changed: 7 additions & 4 deletions

File tree

Lib/http/server.py

Lines changed: 1 addition & 1 deletion

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

0 commit comments

Comments
 (0)