Skip to content
Merged
Changes from 1 commit
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 uvloop/loop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ cdef class Loop:
if reuse_address:
sock.setsockopt(uv.SOL_SOCKET, uv.SO_REUSEADDR, 1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the same problem here with SO_REUSEADDR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No; the place to look is uvloop/includes/stdlib.pxi

cdef int has_IPV6_V6ONLY = hasattr(socket, 'IPV6_V6ONLY')
cdef int IPV6_V6ONLY = getattr(socket, 'IPV6_V6ONLY', -1)
cdef int has_SO_REUSEPORT = hasattr(socket, 'SO_REUSEPORT')
cdef int SO_REUSEPORT = getattr(socket, 'SO_REUSEPORT', 0)

Note that there's a check to see if the variable exists, and then a python definition of the variable with a default, guaranteeing it's defined. This is how the code handles platforms that don't have the constants defined. For other constants (such as SO_REUSEADDR) there's neither a check nor a python definition of the constant.

if reuse_port:
sock.setsockopt(uv.SOL_SOCKET, uv.SO_REUSEPORT, 1)
sock.setsockopt(uv.SOL_SOCKET, SO_REUSEPORT, 1)
# Disable IPv4/IPv6 dual stack support (enabled by
# default on Linux) which makes a single socket
# listen on both address families.
Expand Down