mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
[3.13] gh-128916: Do not set SO_REUSEPORT
on non-AF_INET*
sockets (GH-128933) (#128969)
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
---------
(cherry picked from commit 3829104ab4
)
Co-authored-by: Michał Górny <mgorny@gentoo.org>
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
This commit is contained in:
parent
77e29c75da
commit
d8a442637b
4 changed files with 15 additions and 3 deletions
|
@ -1590,7 +1590,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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue