aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_select.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-12-28 15:14:11 +0100
committerKim Alvefur <zash@zash.se>2012-12-28 15:14:11 +0100
commit18d85d2a745f67eb48fdf20328e81857e04c6261 (patch)
tree0203d6bd6df69296fe7defc78a44293a3e08767d /net/server_select.lua
parent61201a751bacfdfc9e019d9801750be70cf79f46 (diff)
parent4f4bc7973a3f9f754b4576403b9da8d304472055 (diff)
downloadprosody-18d85d2a745f67eb48fdf20328e81857e04c6261.tar.gz
prosody-18d85d2a745f67eb48fdf20328e81857e04c6261.zip
Merge 0.9->trunk
Diffstat (limited to 'net/server_select.lua')
-rw-r--r--net/server_select.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/net/server_select.lua b/net/server_select.lua
index 8cb4e235..97b9f199 100644
--- a/net/server_select.lua
+++ b/net/server_select.lua
@@ -185,6 +185,9 @@ wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx, maxco
end
handler.remove = function( )
connections = connections - 1
+ if handler then
+ handler.resume( )
+ end
end
handler.close = function()
socket:close( )
@@ -197,6 +200,25 @@ wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx, maxco
--mem_free( )
out_put "server.lua: closed server handler and removed sockets from list"
end
+ handler.pause = function()
+ if not handler.paused then
+ socket:close( )
+ _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
+ _readlistlen = removesocket( _readlist, socket, _readlistlen )
+ _socketlist[ socket ] = nil
+ socket = nil;
+ handler.paused = true;
+ end
+ end
+ handler.resume = function()
+ if handler.paused then
+ socket = socket_bind( ip, serverport );
+ socket:settimeout( 0 )
+ _readlistlen = addsocket(_readlist, socket, _readlistlen)
+ _socketlist[ socket ] = handler
+ handler.paused = false;
+ end
+ end
handler.ip = function( )
return ip
end
@@ -208,6 +230,7 @@ wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx, maxco
end
handler.readbuffer = function( )
if connections > maxconnections then
+ handler.pause( )
out_put( "server.lua: refused new client connection: server full" )
return false
end