From 554ca8bd8c97fa6e38d7cc76176ba16ab6889502 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 22 Jan 2016 01:59:25 +0100 Subject: server_select: Retry accepting clients from full servers after 10s (matches libevent behaviour) --- net/server.lua | 2 +- net/server_select.lua | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'net') diff --git a/net/server.lua b/net/server.lua index 375e7081..9b0d27e1 100644 --- a/net/server.lua +++ b/net/server.lua @@ -50,7 +50,7 @@ if prosody then local settings = config_get("*", "network_settings") or {}; if use_luaevent then local event_settings = { - ACCEPT_DELAY = settings.event_accept_retry_interval; + ACCEPT_DELAY = settings.accept_retry_interval; ACCEPT_QUEUE = settings.tcp_backlog; CLEAR_DELAY = settings.event_clear_interval; CONNECT_TIMEOUT = settings.connect_timeout; diff --git a/net/server_select.lua b/net/server_select.lua index 0a060c9e..f9d8dba1 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -103,6 +103,7 @@ local _readtraffic local _selecttimeout local _sleeptime local _tcpbacklog +local _accepretry local _starttime local _currenttime @@ -143,6 +144,7 @@ _readtraffic = 0 _selecttimeout = 1 -- timeout of socket.select _sleeptime = 0 -- time to wait at the end of every loop _tcpbacklog = 128 -- some kind of hint to the OS +_accepretry = 10 -- seconds to wait until the next attempt of a full server to accept _maxsendlen = 51000 * 1024 -- max len of send buffer _maxreadlen = 25000 * 1024 -- max len of read buffer @@ -798,6 +800,7 @@ getsettings = function( ) max_connections = _maxselectlen; max_ssl_handshake_roundtrips = _maxsslhandshake; highest_allowed_fd = _maxfd; + accept_retry_interval = _accepretry; } end @@ -813,6 +816,7 @@ changesettings = function( new ) _tcpbacklog = tonumber( new.tcp_backlog ) or _tcpbacklog _sendtimeout = tonumber( new.send_timeout ) or _sendtimeout _readtimeout = tonumber( new.read_timeout ) or _readtimeout + _accepretry = tonumber( new.accept_retry_interval ) or _accepretry _maxselectlen = new.max_connections or _maxselectlen _maxsslhandshake = new.max_ssl_handshake_roundtrips or _maxsslhandshake _maxfd = new.highest_allowed_fd or _maxfd @@ -901,6 +905,13 @@ loop = function(once) -- this is the main loop of the program next_timer_time = next_timer_time - (_currenttime - _timer); end + for server, paused_time in pairs( _fullservers ) do + if _currenttime - paused_time > _accepretry then + _fullservers[ server ] = nil; + server.resume(); + end + end + -- wait some time (0 by default) socket_sleep( _sleeptime ) until quitting; -- cgit v1.2.3