aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-10-14 14:09:51 +0100
committerMatthew Wild <mwild1@gmail.com>2009-10-14 14:09:51 +0100
commit68f948425a7f0665fbbea3b35393f23eec256516 (patch)
tree300064b6c45539fcad84dc97f34825635bcf0959
parent1fe62686b100b51fb740f93efcbfb1646fcb11d3 (diff)
downloadprosody-68f948425a7f0665fbbea3b35393f23eec256516.tar.gz
prosody-68f948425a7f0665fbbea3b35393f23eec256516.zip
net.server: Better handling of closing sockets during send
-rw-r--r--net/server.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/net/server.lua b/net/server.lua
index a6c57e41..3873a5f0 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -363,17 +363,20 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
send( socket, table_concat( bufferqueue, "", 1, bufferqueuelen ), 1, bufferlen ) -- forced send
end
end
- if not handler then return true; end
- _ = shutdown and shutdown( socket )
- socket:close( )
- _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
- _socketlist[ socket ] = nil
+ if socket then
+ _ = shutdown and shutdown( socket )
+ socket:close( )
+ _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
+ _socketlist[ socket ] = nil
+ socket = nil
+ else
+ out_put "server.lua: socket already closed"
+ end
if handler then
_writetimes[ handler ] = nil
_closelist[ handler ] = nil
handler = nil
end
- socket = nil
mem_free( )
if server then
server.remove( )