From eed7b36b59d97bc74a0065e937d33a1a041a2ff2 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Tue, 4 Sep 2007 17:38:02 -0500 Subject: handle timeout errors in DCC SEND packets --- src/irc/dcc.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/irc/dcc.lua b/src/irc/dcc.lua index 8e71de7..b4db9d1 100644 --- a/src/irc/dcc.lua +++ b/src/irc/dcc.lua @@ -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) -- cgit v1.2.3