[geary] Stop progress monitor when open has completed: Closes bug #728936



commit 8d407a7baa04b784f6287337b435dd12786358d7
Author: Jim Nelson <jim yorba org>
Date:   Tue May 13 13:44:35 2014 -0700

    Stop progress monitor when open has completed: Closes bug #728936
    
    This ensures the progress monitor has stopped when opening has
    completed, whether successful or due to error.  Because the
    remote_open_async() call can be reentered if a connection re-
    establishment is attempted, important to stop the monitor before
    calling close_internal_async().

 .../imap-engine/imap-engine-minimal-folder.vala    |   13 +++++++++++--
 1 files changed, 11 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 851cc4c..631ec6a 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -541,6 +541,9 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
         if (open_count == 0)
             return;
         
+        // to ensure this isn't running when open_remote_async() is called again (due to a connection
+        // reestablishment), stop this monitoring from running *before* launching close_internal_async
+        // ... in essence, guard against reentrancy, which is possible
         opening_monitor.notify_start();
         
         Imap.Folder? opening_folder = null;
@@ -580,6 +583,9 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
                     debug("Error closing remote folder %s: %s", opening_folder.to_string(), err.message);
                 }
                 
+                // stop before starting the close
+                opening_monitor.notify_finish();
+                
                 // schedule immediate close
                 close_internal_async.begin(CloseReason.LOCAL_CLOSE, CloseReason.REMOTE_CLOSE, false,
                     cancellable);
@@ -627,15 +633,18 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
                 debug("Error closing remote folder %s: %s", opening_folder.to_string(), err.message);
             }
             
+            // stop before starting the close
+            opening_monitor.notify_finish();
+            
             // schedule immediate close and force reestablishment
             close_internal_async.begin(CloseReason.LOCAL_CLOSE, remote_reason, force_reestablishment,
                 cancellable);
             
             return;
-        } finally {
-            opening_monitor.notify_finish();
         }
         
+        opening_monitor.notify_finish();
+        
         // open success, reset reestablishment delay
         reestablish_delay_msec = DEFAULT_REESTABLISH_DELAY_MSEC;
         


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