mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
Fix to prevent send retry when connection is already closed
This commit is contained in:
parent
a6970f5b2b
commit
49e7fdc364
1 changed files with 9 additions and 6 deletions
|
@ -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 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue