From 49e7fdc3641d412592fe905ab7a6ed15cfbf72c1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 18 Nov 2008 22:16:06 +0000 Subject: Fix to prevent send retry when connection is already closed --- net/server.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'net') diff --git a/net/server.lua b/net/server.lua index dece7273..3ff777d5 100644 --- a/net/server.lua +++ b/net/server.lua @@ -190,7 +190,7 @@ wrapsslclient = function( listener, socket, ip, serverport, clientport, mode, ss local writequeue = { } -- buffer for messages to send - local eol -- end of buffer + local eol, fatal_send_error -- end of buffer local sstat, rstat = 0, 0 @@ -225,7 +225,7 @@ wrapsslclient = function( listener, socket, ip, serverport, clientport, mode, ss --return shutdown( socket, pattern ) end handler.close = function( closed ) - if eol then handler._dispatchdata(); end + if eol and not fatal_send_error then handler._dispatchdata(); end close( socket ) writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen readlen = removesocket( readlist, socket, readlen ) @@ -296,6 +296,7 @@ wrapsslclient = function( listener, socket, ip, serverport, clientport, mode, ss eol = 1 return true else -- connection was closed during sending or fatal error + fatal_send_error = true; out_put( "server.lua: client ", ip, ":", clientport, " error: ", err ) handler.close( ) disconnect( handler, err ) @@ -371,7 +372,7 @@ wraptlsclient = function( listener, socket, ip, serverport, clientport, mode, ss local writequeue = { } -- buffer for messages to send - local eol -- end of buffer + local eol, fatal_send_error -- end of buffer local sstat, rstat = 0, 0 @@ -406,7 +407,7 @@ wraptlsclient = function( listener, socket, ip, serverport, clientport, mode, ss --return shutdown( socket, pattern ) end handler.close = function( closed ) - if eol then handler._dispatchdata(); end + if eol and not fatal_send_error then handler._dispatchdata(); end close( socket ) writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen readlen = removesocket( readlist, socket, readlen ) @@ -484,6 +485,7 @@ wraptlsclient = function( listener, socket, ip, serverport, clientport, mode, ss eol = 1 return true else -- connection was closed during sending or fatal error + fatal_send_error = true; -- :( out_put( "server.lua: client ", ip, ":", clientport, " error: ", err ) handler.close( ) disconnect( handler, err ) @@ -582,7 +584,7 @@ wraptcpclient = function( listener, socket, ip, serverport, clientport, mode ) local writequeue = { } -- list for messages to send - local eol + local eol, fatal_send_error local rstat, sstat = 0, 0 @@ -617,7 +619,7 @@ wraptcpclient = function( listener, socket, ip, serverport, clientport, mode ) return shutdown( socket, pattern ) end handler.close = function( closed ) - if eol then handler._dispatchdata(); end + if eol and not fatal_send_error then handler._dispatchdata(); end _ = not closed and shutdown( socket ) _ = not closed and close( socket ) writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen @@ -690,6 +692,7 @@ wraptcpclient = function( listener, socket, ip, serverport, clientport, mode ) eol = 1 return true else -- connection was closed during sending or fatal error + fatal_send_error = true; -- :'-( out_put( "server.lua: client ", ip, ":", clientport, " error: ", err ) handler.close( ) disconnect( handler, err ) -- cgit v1.2.3