aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-01-22 01:59:25 +0100
committerKim Alvefur <zash@zash.se>2016-01-22 01:59:25 +0100
commit773269db7c0f608adeec17ec9376d77d4ccfe935 (patch)
tree040aec336a7e1ea583eab8c6e0e54e72ddae3eda
parentf4631dda0590cb3db8c4f0c350b455be8408b52f (diff)
downloadprosody-773269db7c0f608adeec17ec9376d77d4ccfe935.tar.gz
prosody-773269db7c0f608adeec17ec9376d77d4ccfe935.zip
server_select: Retry accepting clients from full servers after 10s (matches libevent behaviour)
-rw-r--r--net/server.lua2
-rw-r--r--net/server_select.lua11
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;