Changeset

328:a1d25769970f

Flush write queue before closing socket
author Matthew Wild <mwild1@gmail.com>
date Tue, 18 Nov 2008 05:06:50 +0000
parents 327:9439362caacc
children 329:3be63719428e
files net/server.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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