# HG changeset patch # User Matthew Wild # Date 1226984810 0 # Node ID a1d25769970fe4245e830656d94fc3eaf63509b3 # Parent 9439362caacca87334d0827e74441bdfec3f2acb Flush write queue before closing socket diff -r 9439362caacc -r a1d25769970f net/server.lua --- a/net/server.lua Mon Nov 17 18:53:13 2008 +0500 +++ b/net/server.lua Tue Nov 18 05:06:50 2008 +0000 @@ -225,6 +225,7 @@ --return shutdown( socket, pattern ) end handler.close = function( closed ) + if eol then handler._dispatchdata(); end close( socket ) writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen readlen = removesocket( readlist, socket, readlen ) @@ -364,7 +365,8 @@ local err socket:settimeout( 0 ) - + out_put("setting linger on "..tostring(socket)) + socket:setoption("linger", { on = true, timeout = 10 }); --// private closures of the object //-- local writequeue = { } -- buffer for messages to send @@ -404,6 +406,7 @@ --return shutdown( socket, pattern ) end handler.close = function( closed ) + if eol then handler._dispatchdata(); end close( socket ) writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen readlen = removesocket( readlist, socket, readlen ) @@ -614,6 +617,7 @@ return shutdown( socket, pattern ) end handler.close = function( closed ) + if eol then handler._dispatchdata(); end _ = not closed and shutdown( socket ) _ = not closed and close( socket ) writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen