Software /
code /
prosody
Changeset
7095:3e1dac35af87
server_select: Retry accepting clients from full servers after 10s (matches libevent behaviour)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 22 Jan 2016 01:59:25 +0100 |
parents | 7094:e8f202856fc0 |
children | 7096:95e4c81291cc |
files | net/server.lua net/server_select.lua |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server.lua Fri Jan 22 01:58:39 2016 +0100 +++ b/net/server.lua Fri Jan 22 01:59:25 2016 +0100 @@ -50,7 +50,7 @@ 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;
--- a/net/server_select.lua Fri Jan 22 01:58:39 2016 +0100 +++ b/net/server_select.lua Fri Jan 22 01:59:25 2016 +0100 @@ -103,6 +103,7 @@ local _selecttimeout local _sleeptime local _tcpbacklog +local _accepretry local _starttime local _currenttime @@ -143,6 +144,7 @@ _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 @@ max_connections = _maxselectlen; max_ssl_handshake_roundtrips = _maxsslhandshake; highest_allowed_fd = _maxfd; + accept_retry_interval = _accepretry; } end @@ -813,6 +816,7 @@ _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 @@ 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;