]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
virtual plugin: Fixed assert-crash when backend mailbox was auto-closed while it...
authorTimo Sirainen <tss@iki.fi>
Fri, 24 Oct 2014 23:13:36 +0000 (02:13 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 24 Oct 2014 23:13:36 +0000 (02:13 +0300)
src/plugins/virtual/virtual-storage.c
src/plugins/virtual/virtual-sync.c

index 13173238826ba95ad63c1df38dff336dc112baa0..fa0297ea609dd2cde527a73d81bba3342a5c1f0a 100644 (file)
@@ -271,6 +271,21 @@ void virtual_backend_box_sync_mail_unset(struct virtual_backend_box *bbox)
        }
 }
 
+static bool virtual_backend_box_can_close(struct virtual_backend_box *bbox)
+{
+       if (bbox->box->notify_callback != NULL) {
+               /* FIXME: IMAP IDLE running - we should support closing this
+                  also if mailbox_list_index=yes */
+               return FALSE;
+       }
+       if (array_count(&bbox->sync_pending_removes) > 0) {
+               /* FIXME: we could probably close this by making
+                  syncing support it? */
+               return FALSE;
+       }
+       return TRUE;
+}
+
 static bool
 virtual_backend_box_close_any_except(struct virtual_mailbox *mbox,
                                     struct virtual_backend_box *except_bbox)
@@ -285,7 +300,7 @@ virtual_backend_box_close_any_except(struct virtual_mailbox *mbox,
 
                if (bbox != except_bbox &&
                    bbox->box->transaction_count == 0 &&
-                   bbox->box->notify_callback == NULL) {
+                   virtual_backend_box_can_close(bbox)) {
                        i_assert(bbox->sync_mail == NULL);
                        virtual_backend_box_close(mbox, bbox);
                        return TRUE;
@@ -298,7 +313,7 @@ virtual_backend_box_close_any_except(struct virtual_mailbox *mbox,
                if (bbox != except_bbox &&
                    bbox->sync_mail != NULL &&
                    bbox->box->transaction_count == 1 &&
-                   bbox->box->notify_callback == NULL) {
+                   virtual_backend_box_can_close(bbox)) {
                        virtual_backend_box_sync_mail_unset(bbox);
                        i_assert(bbox->box->transaction_count == 0);
                        virtual_backend_box_close(mbox, bbox);
index 13cac03fce28b129cc7f6c94b2f5947d6f6ac3b3..ea199ce29fe7a8fbfe542aea72c2ceaf6eae1be1 100644 (file)
@@ -1108,12 +1108,13 @@ static int virtual_sync_backend_box(struct virtual_sync_context *ctx,
                                   MAILBOX_SYNC_FLAG_FAST);
 
        if (bbox->search_result == NULL) {
-               /* first sync in this process. first try to quickly check
-                  if the mailbox has changed. if we can do that check from
-                  mailbox list index, we don't even need to open the
-                  mailbox. */
-               i_assert(array_count(&bbox->sync_pending_removes) == 0);
+               /* a) first sync in this process.
+                  b) we had auto-closed this backend mailbox.
 
+                  first try to quickly check if the mailbox has changed.
+                  if we can do that check from mailbox list index, we don't
+                  even need to open the mailbox. */
+               i_assert(array_count(&bbox->sync_pending_removes) == 0);
                if (bbox_index_opened || bbox->open_failed) {
                        /* a) index already opened, refresh it
                           b) delayed error handling for mailbox_open()