diff --git a/gunicorn/sock.py b/gunicorn/sock.py index eb2b6fa9c..3c0e6cc86 100644 --- a/gunicorn/sock.py +++ b/gunicorn/sock.py @@ -36,10 +36,13 @@ def __str__(self): def __getattr__(self, name): return getattr(self.sock, name) + def supports_reuseport(self): + return hasattr(socket, 'SO_REUSEPORT') + def set_options(self, sock, bound=False): sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) if (self.conf.reuse_port - and hasattr(socket, 'SO_REUSEPORT')): # pragma: no cover + and self.supports_reuseport()): # pragma: no cover try: sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) except OSError as err: @@ -119,6 +122,9 @@ def __init__(self, addr, conf, log, fd=None): def __str__(self): return "unix:%s" % self.cfg_addr + def supports_reuseport(self): + return False + def bind(self, sock): old_umask = os.umask(self.conf.umask) sock.bind(self.cfg_addr)