Comparison

net/server.lua @ 999:c088139d8f05

net.server: Fix potential nil handler usage
author Matthew Wild <mwild1@gmail.com>
date Fri, 17 Apr 2009 16:11:11 +0100
parent 996:6fb96dffb2c1
child 1035:8cc7e4452b2b
child 1098:37ea264e133d
comparison
equal deleted inserted replaced
997:c81b6141d693 999:c088139d8f05
323 _readtimes[ handler ] = nil 323 _readtimes[ handler ] = nil
324 if bufferqueuelen ~= 0 then 324 if bufferqueuelen ~= 0 then
325 if not ( forced or fatalerror ) then 325 if not ( forced or fatalerror ) then
326 handler.sendbuffer( ) 326 handler.sendbuffer( )
327 if bufferqueuelen ~= 0 then -- try again... 327 if bufferqueuelen ~= 0 then -- try again...
328 handler.write = nil -- ... but no further writing allowed 328 if handler then
329 handler.write = nil -- ... but no further writing allowed
330 end
329 toclose = true 331 toclose = true
330 return false 332 return false
331 end 333 end
332 else 334 else
333 send( socket, table_concat( bufferqueue, "", 1, bufferqueuelen ), 1, bufferlen ) -- forced send 335 send( socket, table_concat( bufferqueue, "", 1, bufferqueuelen ), 1, bufferlen ) -- forced send
335 end 337 end
336 _ = shutdown and shutdown( socket ) 338 _ = shutdown and shutdown( socket )
337 socket:close( ) 339 socket:close( )
338 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) 340 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
339 _socketlist[ socket ] = nil 341 _socketlist[ socket ] = nil
340 _writetimes[ handler ] = nil 342 if handler then
341 _closelist[ handler ] = nil 343 _writetimes[ handler ] = nil
342 handler = nil 344 _closelist[ handler ] = nil
345 handler = nil
346 end
343 socket = nil 347 socket = nil
344 mem_free( ) 348 mem_free( )
345 if server then 349 if server then
346 server.remove( ) 350 server.remove( )
347 end 351 end