Comparison

net/server.lua @ 1683:a73b0557d87a

net.server: Comment all calls to mem_free/collectgarbage... not really suitable for a realtime server, let's trust Lua's GC - it's good.
author Matthew Wild <mwild1@gmail.com>
date Sun, 16 Aug 2009 21:32:10 +0100
parent 1612:0413aaf9edae
child 1714:f05a29356269
comparison
equal deleted inserted replaced
1682:883cf1f516a0 1683:a73b0557d87a
244 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) 244 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
245 _readlistlen = removesocket( _readlist, socket, _readlistlen ) 245 _readlistlen = removesocket( _readlist, socket, _readlistlen )
246 _socketlist[ socket ] = nil 246 _socketlist[ socket ] = nil
247 handler = nil 247 handler = nil
248 socket = nil 248 socket = nil
249 mem_free( ) 249 --mem_free( )
250 out_put "server.lua: closed server handler and removed sockets from list" 250 out_put "server.lua: closed server handler and removed sockets from list"
251 end 251 end
252 handler.ip = function( ) 252 handler.ip = function( )
253 return ip 253 return ip
254 end 254 end
371 _writetimes[ handler ] = nil 371 _writetimes[ handler ] = nil
372 _closelist[ handler ] = nil 372 _closelist[ handler ] = nil
373 handler = nil 373 handler = nil
374 end 374 end
375 socket = nil 375 socket = nil
376 mem_free( ) 376 --mem_free( )
377 if server then 377 if server then
378 server.remove( ) 378 server.remove( )
379 end 379 end
380 out_put "server.lua: closed client handler and removed socket from list" 380 out_put "server.lua: closed client handler and removed socket from list"
381 return true 381 return true
557 --out_put("server.lua: ", "starting ssl handshake") 557 --out_put("server.lua: ", "starting ssl handshake")
558 local err 558 local err
559 socket, err = ssl_wrap( socket, sslctx ) -- wrap socket 559 socket, err = ssl_wrap( socket, sslctx ) -- wrap socket
560 if err then 560 if err then
561 out_put( "server.lua: ssl error: ", tostring(err) ) 561 out_put( "server.lua: ssl error: ", tostring(err) )
562 mem_free( ) 562 --mem_free( )
563 return nil, nil, err -- fatal error 563 return nil, nil, err -- fatal error
564 end 564 end
565 socket:settimeout( 0 ) 565 socket:settimeout( 0 )
566 handler.readbuffer = handshake 566 handler.readbuffer = handshake
567 handler.sendbuffer = handshake 567 handler.sendbuffer = handshake
662 closesocket = function( socket ) 662 closesocket = function( socket )
663 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) 663 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
664 _readlistlen = removesocket( _readlist, socket, _readlistlen ) 664 _readlistlen = removesocket( _readlist, socket, _readlistlen )
665 _socketlist[ socket ] = nil 665 _socketlist[ socket ] = nil
666 socket:close( ) 666 socket:close( )
667 mem_free( ) 667 --mem_free( )
668 end 668 end
669 669
670 ----------------------------------// PUBLIC //-- 670 ----------------------------------// PUBLIC //--
671 671
672 addserver = function( listeners, port, addr, pattern, sslctx, maxconnections, startssl ) -- this function provides a way for other scripts to reg a server 672 addserver = function( listeners, port, addr, pattern, sslctx, maxconnections, startssl ) -- this function provides a way for other scripts to reg a server
731 _server = { } 731 _server = { }
732 _readlist = { } 732 _readlist = { }
733 _sendlist = { } 733 _sendlist = { }
734 _timerlist = { } 734 _timerlist = { }
735 _socketlist = { } 735 _socketlist = { }
736 mem_free( ) 736 --mem_free( )
737 end 737 end
738 738
739 getsettings = function( ) 739 getsettings = function( )
740 return _selecttimeout, _sleeptime, _maxsendlen, _maxreadlen, _checkinterval, _sendtimeout, _readtimeout, _cleanqueue, _maxclientsperserver 740 return _selecttimeout, _sleeptime, _maxsendlen, _maxreadlen, _checkinterval, _sendtimeout, _readtimeout, _cleanqueue, _maxclientsperserver
741 end 741 end