Comparison

net/server.lua @ 1952:4a15b176fca8

net.server: Better handling of closing sockets during send
author Matthew Wild <mwild1@gmail.com>
date Wed, 14 Oct 2009 14:09:51 +0100
parent 1863:51b1612325e6
child 1953:64538c620450
comparison
equal deleted inserted replaced
1951:632039101699 1952:4a15b176fca8
361 end 361 end
362 else 362 else
363 send( socket, table_concat( bufferqueue, "", 1, bufferqueuelen ), 1, bufferlen ) -- forced send 363 send( socket, table_concat( bufferqueue, "", 1, bufferqueuelen ), 1, bufferlen ) -- forced send
364 end 364 end
365 end 365 end
366 if not handler then return true; end 366 if socket then
367 _ = shutdown and shutdown( socket ) 367 _ = shutdown and shutdown( socket )
368 socket:close( ) 368 socket:close( )
369 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) 369 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
370 _socketlist[ socket ] = nil 370 _socketlist[ socket ] = nil
371 socket = nil
372 else
373 out_put "server.lua: socket already closed"
374 end
371 if handler then 375 if handler then
372 _writetimes[ handler ] = nil 376 _writetimes[ handler ] = nil
373 _closelist[ handler ] = nil 377 _closelist[ handler ] = nil
374 handler = nil 378 handler = nil
375 end 379 end
376 socket = nil
377 mem_free( ) 380 mem_free( )
378 if server then 381 if server then
379 server.remove( ) 382 server.remove( )
380 end 383 end
381 out_put "server.lua: closed client handler and removed socket from list" 384 out_put "server.lua: closed client handler and removed socket from list"