diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-08-18 15:58:44 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-08-18 15:58:44 +0100 |
commit | f3f4b12eb59de6d9d8a77fed797b47702b3fd4df (patch) | |
tree | 2637471a186f5084d114f6ac2551cd2fce8f1e90 /net | |
parent | d8d4b7409ce9b0c63b55c49fe62b29eb1b7e1885 (diff) | |
download | prosody-f3f4b12eb59de6d9d8a77fed797b47702b3fd4df.tar.gz prosody-f3f4b12eb59de6d9d8a77fed797b47702b3fd4df.zip |
net.server: Add checking for nil sockets to prevent traceback
Diffstat (limited to 'net')
-rw-r--r-- | net/server.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/net/server.lua b/net/server.lua index 966006c1..12b0aa90 100644 --- a/net/server.lua +++ b/net/server.lua @@ -483,13 +483,19 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport end
end
local _sendbuffer = function( ) -- this function sends data
- local buffer = table_concat( bufferqueue, "", 1, bufferqueuelen )
- local succ, err, byte = send( socket, buffer, 1, bufferlen )
- local count = ( succ or byte or 0 ) * STAT_UNIT
- sendtraffic = sendtraffic + count
- _sendtraffic = _sendtraffic + count
- _ = _cleanqueue and clean( bufferqueue )
- --out_put( "server.lua: sended '", buffer, "', bytes: ", tostring(succ), ", error: ", tostring(err), ", part: ", tostring(byte), ", to: ", tostring(ip), ":", tostring(clientport) )
+ local succ, err, byte, buffer, count;
+ local count;
+ if socket then
+ buffer = table_concat( bufferqueue, "", 1, bufferqueuelen )
+ succ, err, byte = send( socket, buffer, 1, bufferlen )
+ count = ( succ or byte or 0 ) * STAT_UNIT
+ sendtraffic = sendtraffic + count
+ _sendtraffic = _sendtraffic + count
+ _ = _cleanqueue and clean( bufferqueue )
+ --out_put( "server.lua: sended '", buffer, "', bytes: ", tostring(succ), ", error: ", tostring(err), ", part: ", tostring(byte), ", to: ", tostring(ip), ":", tostring(clientport) )
+ else
+ succ, err, count = false, "closed", 0;
+ end
if succ then -- sending succesful
bufferqueuelen = 0
bufferlen = 0
|