Skip to content

gh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP servers #135405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
class HTTPServer(socketserver.TCPServer):

allow_reuse_address = True # Seems to make sense in testing environment
allow_reuse_port = True
allow_reuse_port = False

def server_bind(self):
"""Override server_bind to store the server name."""
Expand Down
2 changes: 1 addition & 1 deletion Lib/logging/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ class ConfigSocketReceiver(ThreadingTCPServer):
"""

allow_reuse_address = True
allow_reuse_port = True
allow_reuse_port = False

def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT,
handler=None, ready=None, verify=None):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ class TestTCPServer(ControlMixin, ThreadingTCPServer):
"""

allow_reuse_address = True
allow_reuse_port = True
allow_reuse_port = False

def __init__(self, addr, handler, poll_interval=0.5,
bind_and_activate=True):
Expand Down
2 changes: 1 addition & 1 deletion Lib/xmlrpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer,
"""

allow_reuse_address = True
allow_reuse_port = True
allow_reuse_port = False

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