aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-01-22 01:58:39 +0100
committerKim Alvefur <zash@zash.se>2016-01-22 01:58:39 +0100
commita1560114d0e51c74fb724a2b3577b7b230a79a50 (patch)
tree1524943a561d71bef64fba519830d2a5233f50c7
parentecf5de4a4deb14356c5ceb45e963d2c7e0763b58 (diff)
downloadprosody-a1560114d0e51c74fb724a2b3577b7b230a79a50.tar.gz
prosody-a1560114d0e51c74fb724a2b3577b7b230a79a50.zip
server_select: Keep track of which server listeners are full
-rw-r--r--net/server_select.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/server_select.lua b/net/server_select.lua
index 7ac41523..0a060c9e 100644
--- a/net/server_select.lua
+++ b/net/server_select.lua
@@ -88,6 +88,7 @@ local _socketlist
local _closelist
local _readtimes
local _writetimes
+local _fullservers
--// simple data types //--
@@ -130,6 +131,7 @@ _socketlist = { } -- key = socket, value = wrapped socket (handlers)
_readtimes = { } -- key = handler, value = timestamp of last data reading
_writetimes = { } -- key = handler, value = timestamp of last data writing/sending
_closelist = { } -- handlers to close
+_fullservers = { } -- servers in a paused state while there are too many clients
_readlistlen = 0 -- length of readlist
_sendlistlen = 0 -- length of sendlist
@@ -219,6 +221,7 @@ wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx ) -- t
end
_readlistlen = addsocket(_readlist, socket, _readlistlen)
_socketlist[ socket ] = handler
+ _fullservers[ handler ] = nil
handler.paused = false;
end
end
@@ -234,6 +237,7 @@ wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx ) -- t
handler.readbuffer = function( )
if _readlistlen >= _maxselectlen or _sendlistlen >= _maxselectlen then
handler.pause( )
+ _fullservers[ handler ] = _currenttime
out_put( "server.lua: refused new client connection: server full" )
return false
end
@@ -264,6 +268,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
out_error("server.lua: Disallowed FD number: "..socket:getfd()) -- PROTIP: Switch to libevent
socket:close( ) -- Should we send some kind of error here?
if server then
+ _fullservers[ server ] = _currenttime
server.pause( )
end
return nil, nil, "fd-too-large"