Merge with waqas

Tue, 18 Aug 2009 15:59:58 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 18 Aug 2009 15:59:58 +0100
changeset 1717
beadd8da061c
parent 1715
3a5b6cd6b8c9 (diff)
parent 1716
3f7fd1445d02 (current diff)
child 1718
af3d0c329396

Merge with waqas

--- a/net/adns.lua	Tue Aug 18 19:56:16 2009 +0500
+++ b/net/adns.lua	Tue Aug 18 15:59:58 2009 +0100
@@ -50,6 +50,12 @@
 	function listener.disconnect()
 	end
 	newconn.handler, newconn._socket = server.wrapclient(sock, "dns", 53, listener);
+	if not newconn.handler then
+		log("warn", "handler is nil");
+	end
+	if not newconn._socket then
+		log("warn", "socket is nil");
+	end
 	newconn.handler.settimeout = function () end
 	newconn.handler.setsockname = function (_, ...) return sock:setsockname(...); end
 	newconn.handler.setpeername = function (_, ...) local ret = sock:setpeername(...); _.setsend(sock.send); return ret; end
--- a/net/server.lua	Tue Aug 18 19:56:16 2009 +0500
+++ b/net/server.lua	Tue Aug 18 15:59:58 2009 +0100
@@ -483,13 +483,19 @@
         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

mercurial