Allow reuse of socket (works without SELinux, probably no longer needed with proper workaround)
This commit is contained in:
@@ -63,6 +63,12 @@ def _fd_to_socket(fd: int) -> socket.socket:
|
||||
# ``family``, ``type`` and ``proto`` attributes.
|
||||
sock = socket.socket(fileno=fd)
|
||||
|
||||
# Allow aiohttp to call listen() again without EPERM.
|
||||
# On many Linux kernels the flag must be set *before* the first listen(),
|
||||
# but systemd binds the socket without it. Setting it now is sufficient
|
||||
# for the second listen() performed by aiohttp.
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
|
||||
|
||||
# aiohttp’s SockSite registers the socket with the event loop, which
|
||||
# requires a non‑blocking descriptor.
|
||||
sock.setblocking(False)
|
||||
|
||||
Reference in New Issue
Block a user