mirror of
https://github.com/aaiyer/rfoo.git
synced 2025-04-22 03:40:30 +03:00
Possibility to set socket listen backlog.
Setting this parameter to a higher value prevents TCP listen overflows (connection reset) on very busy sites
This commit is contained in:
parent
1555bd4eed
commit
accff0c292
@ -466,15 +466,15 @@ class Server(object):
|
||||
pass
|
||||
self._conn.close()
|
||||
|
||||
def start(self):
|
||||
def start(self, listen_backlog = 5):
|
||||
"""Start server, is it?
|
||||
Socket is excpted bound.
|
||||
"""
|
||||
|
||||
logging.info('Enter.')
|
||||
|
||||
assert listen_backlog > 0, "Listen backlog must be greater than zero"
|
||||
try:
|
||||
self._conn.listen(5)
|
||||
self._conn.listen(listen_backlog)
|
||||
|
||||
while True:
|
||||
if self.stopped():
|
||||
@ -567,9 +567,9 @@ class InetServer(Server):
|
||||
s.settimeout(None)
|
||||
Server.__init__(self, handler_type, handler_context, s, None, timeout)
|
||||
|
||||
def start(self, host=LOOPBACK, port=DEFAULT_PORT):
|
||||
def start(self, host=LOOPBACK, port=DEFAULT_PORT, listen_backlog = 5):
|
||||
self._conn.bind((host, port))
|
||||
Server.start(self)
|
||||
Server.start(self, listen_backlog)
|
||||
|
||||
_on_accept = run_in_thread(Server._on_accept)
|
||||
|
||||
@ -586,9 +586,9 @@ class SSLServer(Server):
|
||||
context.load_cert_chain(certfile=certfile, keyfile=keyfile)
|
||||
Server.__init__(self, handler_type, handler_context, s, ssl_context, timeout)
|
||||
|
||||
def start(self, host=LOOPBACK, port=DEFAULT_PORT):
|
||||
def start(self, host=LOOPBACK, port=DEFAULT_PORT, listen_backlog = 5):
|
||||
self._conn.bind((host, port))
|
||||
Server.start(self)
|
||||
Server.start(self, listen_backlog)
|
||||
|
||||
_on_accept = run_in_thread(Server._on_accept)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user