[geary/wip/789924-network-transition-redux: 56/64] Ensure MinimalFolder is only closed at most once if open_count is 1.



commit 61f739b12838f69e0dc8afafe2759ff95f7e5df5
Author: Michael James Gratton <mike vee net>
Date:   Wed Feb 21 16:47:20 2018 +1100

    Ensure MinimalFolder is only closed at most once if open_count is 1.

 .../imap-engine/imap-engine-minimal-folder.vala    |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala 
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index 1888dcb..94a8adb 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -326,7 +326,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
                             CloseReason.REMOTE_CLOSE,
                             cancellable
                         );
-                    } else if (this.open_count >= 1) {
+                    } else if (this.open_count > 1) {
                         this.open_count -= 1;
                     }
                     return is_closing;
@@ -758,9 +758,14 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
                                       Cancellable? cancellable) {
         try {
             int token = yield this.close_mutex.claim_async(cancellable);
-            yield close_internal_locked(
-                local_reason, remote_reason, cancellable
-            );
+            // Only actually close if we are still open. This guards
+            // against e.g. multiple callers calling when the open
+            // count is 1.
+            if (this.open_count > 0) {
+                yield close_internal_locked(
+                    local_reason, remote_reason, cancellable
+                );
+            }
             this.close_mutex.release(ref token);
         } catch (Error err) {
             // oh well


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