Comparison

net/server_select.lua @ 5280:1514a6147e85

net.server_select: Pause servers while they are full
author Kim Alvefur <zash@zash.se>
date Fri, 28 Dec 2012 14:33:27 +0100
parent 5279:e8f7962056f5
child 5288:2777f34adbd3
comparison
equal deleted inserted replaced
5279:e8f7962056f5 5280:1514a6147e85
183 handler.sslctx = function( ) 183 handler.sslctx = function( )
184 return sslctx 184 return sslctx
185 end 185 end
186 handler.remove = function( ) 186 handler.remove = function( )
187 connections = connections - 1 187 connections = connections - 1
188 if handler then
189 handler.resume( )
190 end
188 end 191 end
189 handler.close = function() 192 handler.close = function()
190 socket:close( ) 193 socket:close( )
191 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) 194 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
192 _readlistlen = removesocket( _readlist, socket, _readlistlen ) 195 _readlistlen = removesocket( _readlist, socket, _readlistlen )
225 handler.socket = function( ) 228 handler.socket = function( )
226 return socket 229 return socket
227 end 230 end
228 handler.readbuffer = function( ) 231 handler.readbuffer = function( )
229 if connections > maxconnections then 232 if connections > maxconnections then
233 handler.pause( )
230 out_put( "server.lua: refused new client connection: server full" ) 234 out_put( "server.lua: refused new client connection: server full" )
231 return false 235 return false
232 end 236 end
233 local client, err = accept( socket ) -- try to accept 237 local client, err = accept( socket ) -- try to accept
234 if client then 238 if client then