aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/adns.lua6
-rw-r--r--net/server.lua20
2 files changed, 19 insertions, 7 deletions
diff --git a/net/adns.lua b/net/adns.lua
index 34ef5d77..7ee54da3 100644
--- a/net/adns.lua
+++ b/net/adns.lua
@@ -50,6 +50,12 @@ function new_async_socket(sock)
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
diff --git a/net/server.lua b/net/server.lua
index 069db50f..65567d15 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