[haiku-commits] r40894 - haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 10 Mar 2011 02:31:33 +0100 (CET)

Author: czeidler
Date: 2011-03-10 02:31:33 +0100 (Thu, 10 Mar 2011)
New Revision: 40894
Changeset: http://dev.haiku-os.org/changeset/40894

Modified:
   
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp
   
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp
   
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.h
Log:
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.



Modified: 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp
 2011-03-09 22:29:46 UTC (rev 40893)
+++ 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPMailbox.cpp
 2011-03-10 01:31:33 UTC (rev 40894)
@@ -127,7 +127,7 @@
        //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 @@
                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)

Modified: 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp
        2011-03-09 22:29:46 UTC (rev 40893)
+++ 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp
        2011-03-10 01:31:33 UTC (rev 40894)
@@ -303,7 +303,7 @@
 
 
 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 @@
                BString line;
                status_t status = fConnectionReader.GetNextLine(line, timeout);
                if (status != B_OK) {
-                       if (status != B_TIMED_OUT)
+                       // we might lost the connection, clear the connection 
state
+                       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();
+                               _Disconnect();
+                       } else if (disconnectOnTimeout) {
+                               _Disconnect();                          
+                       }
                        return status;
                }
                //TRACE("S: %s", line.String());

Modified: 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.h
===================================================================
--- 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.h
  2011-03-09 22:29:46 UTC (rev 40893)
+++ 
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.h
  2011-03-10 01:31:33 UTC (rev 40894)
@@ -94,7 +94,8 @@
                        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();
 


Other related posts:

  • » [haiku-commits] r40894 - haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib - clemens . zeidler