From c91bb36337e4fb0b67f6e4d8d83be54116b6dcf8 Mon Sep 17 00:00:00 2001 From: Cedric RICARD Date: Thu, 22 Apr 2010 23:42:12 +0000 Subject: [PATCH] Fix for smtp_client.anubis --- calexium_lib/mail/smtp_client.anubis | 58 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/calexium_lib/mail/smtp_client.anubis b/calexium_lib/mail/smtp_client.anubis index 447ddbc..58f6c47 100644 --- a/calexium_lib/mail/smtp_client.anubis +++ b/calexium_lib/mail/smtp_client.anubis @@ -406,9 +406,9 @@ define Maybe(One) { failure then failure, success(nb_write) then - if now - buffer_start_time > 3600 then + if now - buffer_start_time > 120 then // security to avoid queue blocking - logger(logError, "sm_flush: TIMEOUT sending a 64kb buffer (taking more than 1 hour). SendMail canceled."); + logger(logError, "sm_flush: TIMEOUT sending a " + length(buffer) + " byte-length buffer (taking more than 2 minutes). SendMail canceled."); failure else with buffer_size = length(buffer), @@ -427,44 +427,38 @@ define SendContentResult SmtpClientSession session, Int start_time, Int so_far, + Int last_reply_check, (Int) -> One progress_report, (LogLevel, String) -> One logger ) = - if receive_reply(weaken(target), [], session.enhanced_status, 0, logger) is - { - error then copy_error(so_far), - timeout then - if read_bytes(source, 65536) is + if last_reply_check + 60 < now then + if receive_reply(weaken(target), [], session.enhanced_status, 0, logger) is + { + error then copy_error(so_far), + timeout then + sm_copy_Data_IO_to_Stream(source, target, session, start_time, so_far, now, progress_report, logger) + no_auth_method then copy_error(so_far), // impossible + bad_reply then copy_error(so_far), + reply(code, status, lines) then + smtp_reply(reply(code, status, lines)) + } + else + if read_line(source, 1024) is { - failure then logger(logError, "send_content: failed to read input data_io"); copy_error(so_far), - time_out then logger(logError, "send_content: timeout reading input data_io"); copy_error(so_far), - success(buffer) then + error then logger(logError, "send_content: failed to read input data_io"); copy_error(so_far), + timeout then logger(logError, "send_content: timeout reading input data_io"); copy_error(so_far), + eof then copy_ok(so_far), + ok(line) then + with buffer = to_byte_array((if nth(0, line) is success(char) then if char = '.' then "." + line else line else line)), if sm_flush( buffer, weaken(target), now, logger ) is { failure then copy_error(so_far), success(_) then - progress_report(so_far + 65536); - sm_copy_Data_IO_to_Stream(source, target, session, start_time, so_far + 65536, progress_report, logger) + with len = length(line) + 2, // 2 is for the CRLF + progress_report(so_far + len); + sm_copy_Data_IO_to_Stream(source, target, session, start_time, so_far + len, last_reply_check, progress_report, logger) }, - - truncated(buffer) then - with len = length(buffer), - if len = 0 then - copy_ok(so_far) - else - if sm_flush( buffer, weaken(target), now, logger ) is - { - failure then copy_error(so_far), - success(_) then - progress_report(so_far + len); - copy_ok(so_far + len) - } - }, - no_auth_method then copy_error(so_far), // impossible - bad_reply then copy_error(so_far), - reply(code, status, lines) then - smtp_reply(reply(code, status, lines)) - }. + }. define SendContentResult sm_copy_Data_IO_List_to_Stream @@ -482,7 +476,7 @@ define SendContentResult [] then copy_ok(so_far), [ h . t ] then if rewind(h)(unique) then - with result = sm_copy_Data_IO_to_Stream(h, target, session, start_time, 0, progress_report, logger), + with result = sm_copy_Data_IO_to_Stream(h, target, session, start_time, 0, now, progress_report, logger), if result is copy_ok(written) then sm_copy_Data_IO_List_to_Stream(t, target, session, start_time, so_far + written, progress_report, logger) else -- libgit2 0.21.4