# HG changeset patch # User Kim Alvefur # Date 1453424319 -3600 # Node ID e8f202856fc0c2a2d9d51721ce7b9110fd3ab1e5 # Parent 388281be2bc7383d2b6b9378aa58709b623eda1b server_select: Keep track of which server listeners are full diff -r 388281be2bc7 -r e8f202856fc0 net/server_select.lua --- a/net/server_select.lua Thu Jan 21 22:26:46 2016 +0100 +++ b/net/server_select.lua Fri Jan 22 01:58:39 2016 +0100 @@ -88,6 +88,7 @@ local _closelist local _readtimes local _writetimes +local _fullservers --// simple data types //-- @@ -130,6 +131,7 @@ _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 @@ end _readlistlen = addsocket(_readlist, socket, _readlistlen) _socketlist[ socket ] = handler + _fullservers[ handler ] = nil handler.paused = false; end end @@ -234,6 +237,7 @@ 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 @@ 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"