aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2025-01-18 01:49:16 +0100
committerGitHub <noreply@github.com>2025-01-17 16:49:16 -0800
commit3829104ab412a47bf3f36b8c133c886d2cc9a6d4 (patch)
tree3f20643b15d5eb0d2e9ff534a98e1186514d2298 /Lib/asyncio
parent8174770d311ba09c07a47cc3ae90a1db2e7d7708 (diff)
downloadcpython-3829104ab412a47bf3f36b8c133c886d2cc9a6d4.tar.gz
cpython-3829104ab412a47bf3f36b8c133c886d2cc9a6d4.zip
gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets (GH-128933)
* gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets Do not attempt to set ``SO_REUSEPORT`` on sockets of address familifies other than ``AF_INET`` and ``AF_INET6``, as it is meaningless with these address families, and the call with fail with Linux kernel 6.12.9 and newer. * Apply suggestions from code review Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk> --------- Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/base_events.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 6e6e5aaac15..85018797db3 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -1593,7 +1593,9 @@ class BaseEventLoop(events.AbstractEventLoop):
if reuse_address:
sock.setsockopt(
socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
- if reuse_port:
+ # Since Linux 6.12.9, SO_REUSEPORT is not allowed
+ # on other address families than AF_INET/AF_INET6.
+ if reuse_port and af in (socket.AF_INET, socket.AF_INET6):
_set_reuseport(sock)
if keep_alive:
sock.setsockopt(