]> git.lizzy.rs Git - luairc.git/commitdiff
handle timeout errors in DCC SEND packets
authorjluehrs2 <jluehrs2@uiuc.edu>
Tue, 4 Sep 2007 22:38:02 +0000 (17:38 -0500)
committerjluehrs2 <jluehrs2@uiuc.edu>
Tue, 4 Sep 2007 22:38:02 +0000 (17:38 -0500)
src/irc/dcc.lua

index 8e71de7b9610ba31248174350494ab13d81793ca..b4db9d11990c771cc88cb896a1af3993eee3748c 100644 (file)
@@ -39,12 +39,25 @@ local function send_file(sock, file, packet_size)
         bytes = bytes + packet:len()
         local index = 1
         while true do
+            local skip = false
             sock:send(packet, index)
-            local new_bytes = misc._int_to_str(sock:receive(4))
-            if new_bytes ~= bytes then
-                index = packet_size - bytes + new_bytes + 1
+            local new_bytes, err = sock:receive(4)
+            if not new_bytes then
+                if err == "timeout" then
+                    skip = true
+                else
+                    irc_debug._warn(err)
+                    break
+                end
             else
-                break
+                new_bytes = misc._int_to_str(new_bytes)
+            end
+            if not skip then
+                if new_bytes ~= bytes then
+                    index = packet_size - bytes + new_bytes + 1
+                else
+                    break
+                end
             end
         end
         coroutine.yield(true)