Comparison

net/server.lua @ 328:a1d25769970f

Flush write queue before closing socket
author Matthew Wild <mwild1@gmail.com>
date Tue, 18 Nov 2008 05:06:50 +0000
parent 319:4a8a949c3870
child 335:906311ff2170
comparison
equal deleted inserted replaced
327:9439362caacc 328:a1d25769970f
223 end 223 end
224 handler.shutdown = function( pattern ) 224 handler.shutdown = function( pattern )
225 --return shutdown( socket, pattern ) 225 --return shutdown( socket, pattern )
226 end 226 end
227 handler.close = function( closed ) 227 handler.close = function( closed )
228 if eol then handler._dispatchdata(); end
228 close( socket ) 229 close( socket )
229 writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen 230 writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen
230 readlen = removesocket( readlist, socket, readlen ) 231 readlen = removesocket( readlist, socket, readlen )
231 socketlist[ socket ] = nil 232 socketlist[ socket ] = nil
232 out_put "server.lua: closed handler and removed socket from list" 233 out_put "server.lua: closed handler and removed socket from list"
362 --// transform socket to ssl object //-- 363 --// transform socket to ssl object //--
363 364
364 local err 365 local err
365 366
366 socket:settimeout( 0 ) 367 socket:settimeout( 0 )
367 368 out_put("setting linger on "..tostring(socket))
369 socket:setoption("linger", { on = true, timeout = 10 });
368 --// private closures of the object //-- 370 --// private closures of the object //--
369 371
370 local writequeue = { } -- buffer for messages to send 372 local writequeue = { } -- buffer for messages to send
371 373
372 local eol -- end of buffer 374 local eol -- end of buffer
402 end 404 end
403 handler.shutdown = function( pattern ) 405 handler.shutdown = function( pattern )
404 --return shutdown( socket, pattern ) 406 --return shutdown( socket, pattern )
405 end 407 end
406 handler.close = function( closed ) 408 handler.close = function( closed )
409 if eol then handler._dispatchdata(); end
407 close( socket ) 410 close( socket )
408 writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen 411 writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen
409 readlen = removesocket( readlist, socket, readlen ) 412 readlen = removesocket( readlist, socket, readlen )
410 socketlist[ socket ] = nil 413 socketlist[ socket ] = nil
411 out_put "server.lua: closed handler and removed socket from list" 414 out_put "server.lua: closed handler and removed socket from list"
612 end 615 end
613 handler.shutdown = function( pattern ) 616 handler.shutdown = function( pattern )
614 return shutdown( socket, pattern ) 617 return shutdown( socket, pattern )
615 end 618 end
616 handler.close = function( closed ) 619 handler.close = function( closed )
620 if eol then handler._dispatchdata(); end
617 _ = not closed and shutdown( socket ) 621 _ = not closed and shutdown( socket )
618 _ = not closed and close( socket ) 622 _ = not closed and close( socket )
619 writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen 623 writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen
620 readlen = removesocket( readlist, socket, readlen ) 624 readlen = removesocket( readlist, socket, readlen )
621 socketlist[ socket ] = nil 625 socketlist[ socket ] = nil