From 8b254785bba2218ddd929cf3b858d6b9a377018d Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Thu, 10 Mar 2011 01:31:33 +0000 Subject: [PATCH] The IDLE watching command is supposed to timeout after 29 min if nothing happens. Add an mechanism to not treat this timeout as an error. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40894 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../inbound_protocols/imap/imap_lib/IMAPMailbox.cpp | 4 ++-- .../inbound_protocols/imap/imap_lib/IMAPProtocol.cpp | 12 +++++++----- .../inbound_protocols/imap/imap_lib/IMAPProtocol.h | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp index 4fa6a94db3..e64e5b47fd 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp @@ -127,7 +127,7 @@ IMAPMailbox::StartWatchingMailbox() //TODO set it when we actually watching atomic_set(&fWatching, 1); - // refresh every 29 min TODO: check if it works this way + // refresh every 29 min bigtime_t timeout = 1000 * 1000 * 60 * 29; // 29 min status_t status; while (true) { @@ -136,7 +136,7 @@ IMAPMailbox::StartWatchingMailbox() status = SendCommand("IDLE", commandId); if (status != B_OK) break; - status = HandleResponse(commandId, timeout); + status = HandleResponse(commandId, timeout, false); ProcessAfterQuacks(kIMAP4ClientTimeout); if (atomic_get(&fWatching) == 0) diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp index 79b512f986..62df05c955 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp @@ -303,7 +303,7 @@ IMAPProtocol::SendCommand(const char* command, int32 commandId) status_t -IMAPProtocol::HandleResponse(int32 commandId, bigtime_t timeout) +IMAPProtocol::HandleResponse(int32 commandId, bigtime_t timeout, bool disconnectOnTimeout) { status_t commandStatus = B_ERROR; @@ -312,11 +312,13 @@ IMAPProtocol::HandleResponse(int32 commandId, bigtime_t timeout) BString line; status_t status = fConnectionReader.GetNextLine(line, timeout); if (status != B_OK) { - if (status != B_TIMED_OUT) - TRACE("S:read error %s", line.String()); // we might lost the connection, clear the connection state - TRACE("Disconnect\n"); - _Disconnect(); + if (status != B_TIMED_OUT) { + TRACE("S:read error %s", line.String()); + _Disconnect(); + } else if (disconnectOnTimeout) { + _Disconnect(); + } return status; } //TRACE("S: %s", line.String()); diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.h b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.h index ec51427e4c..82d6620e1c 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.h +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.h @@ -94,7 +94,8 @@ protected: status_t SendCommand(const char* command, int32 commandId); status_t HandleResponse(int32 commandId, - bigtime_t timeout = kIMAP4ClientTimeout); + bigtime_t timeout = kIMAP4ClientTimeout, + bool disconnectOnTimeout = true); void ProcessAfterQuacks(bigtime_t timeout); int32 NextCommandId();