diff options
author | Kim Alvefur <zash@zash.se> | 2016-01-22 01:59:25 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-01-22 01:59:25 +0100 |
commit | 9d4aae5a44d24b44f22a11f2c1990ac6469845d3 (patch) | |
tree | 040aec336a7e1ea583eab8c6e0e54e72ddae3eda | |
parent | 0a8beb53c654c7158b9b04309c9d94f45e15ad7d (diff) | |
download | prosody-9d4aae5a44d24b44f22a11f2c1990ac6469845d3.tar.gz prosody-9d4aae5a44d24b44f22a11f2c1990ac6469845d3.zip |
server_select: Retry accepting clients from full servers after 10s (matches libevent behaviour)
-rw-r--r-- | net/server.lua | 2 | ||||
-rw-r--r-- | net/server_select.lua | 11 |
2 files changed, 12 insertions, 1 deletions
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; |