[geary/wip/only-incomplete] Watch for open_count being driven up by retrys while open



commit b28ee90c79334e172b6e05b51184ea69db658e5d
Author: Jim Nelson <jim yorba org>
Date:   Tue May 6 17:47:16 2014 -0700

    Watch for open_count being driven up by retrys while open

 .../imap-engine/imap-engine-minimal-folder.vala    |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala 
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index 40e4f92..67f766e 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -8,7 +8,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
     Geary.FolderSupport.Mark, Geary.FolderSupport.Move {
     private const int FORCE_OPEN_REMOTE_TIMEOUT_SEC = 10;
     private const int DEFAULT_REESTABLISH_DELAY_MSEC = 10;
-    private const int MAX_REESTABLISH_DELAY_MSEC = 1000;
+    private const int MAX_REESTABLISH_DELAY_MSEC = 30000;
     
     public override Account account { get { return _account; } }
     
@@ -799,7 +799,8 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
     private static async void close_remote_folder_async(owned MinimalFolder folder,
         owned Imap.Folder? remote_folder, Folder.CloseReason remote_reason, bool force_reestablish) {
         // force the remote closed; if due to a remote disconnect and plan on reopening, *still*
-        // need to do this
+        // need to do this ... don't set remote_folder to null, as that will make some code paths
+        // think the folder is closing or closed when in fact it will be re-opening in a moment
         try {
             if (remote_folder != null)
                 yield remote_folder.close_async(null);
@@ -823,6 +824,10 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
                     folder.reestablish_delay_msec = (folder.reestablish_delay_msec * 2).clamp(
                         DEFAULT_REESTABLISH_DELAY_MSEC, MAX_REESTABLISH_DELAY_MSEC);
                     
+                    // since open_async() increments open_count, artificially decrement here to
+                    // prevent driving the value up
+                    folder.open_count--;
+                    
                     yield folder.open_async(OpenFlags.NO_DELAY, null);
                 } else {
                     debug("%s: Not reestablishing broken connection, folder was closed", folder.to_string());


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]