]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Fix leaking mail_index_view on delayed expunge handling
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 17 Jan 2018 13:05:38 +0000 (15:05 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 18 Jan 2018 10:07:06 +0000 (12:07 +0200)
Fixes:
Panic: Leaked view for index (in-memory index): Opened in imapc-mailbox.c:47

src/lib-storage/index/imapc/imapc-mailbox.c
src/lib-storage/index/imapc/imapc-sync.c

index 90dab90af00ede49957fb16a5331923319959d05..a07b27db88a50febfdaa3fbf504768c4b739d2e7 100644 (file)
@@ -110,15 +110,22 @@ int imapc_mailbox_commit_delayed_trans(struct imapc_mailbox *mbox,
        mbox->delayed_sync_cache_trans = NULL;
        if (mbox->delayed_sync_cache_view != NULL)
                mail_cache_view_close(&mbox->delayed_sync_cache_view);
-       if (mbox->sync_view != NULL)
-               mail_index_view_close(&mbox->sync_view);
 
        if (array_count(&mbox->delayed_expunged_uids) > 0) {
                /* delayed expunges - commit them now in a separate
-                  transaction */
+                  transaction. Reopen mbox->sync_view to see changes
+                  committed in delayed_sync_trans. */
+               if (mbox->sync_view != NULL)
+                       mail_index_view_close(&mbox->sync_view);
                if (imapc_mailbox_commit_delayed_expunges(mbox) < 0)
                        ret = -1;
        }
+
+       if (mbox->sync_view != NULL)
+               mail_index_view_close(&mbox->sync_view);
+       i_assert(mbox->delayed_sync_trans == NULL);
+       i_assert(mbox->delayed_sync_view == NULL);
+       i_assert(mbox->delayed_sync_cache_trans == NULL);
        return ret;
 }
 
index f8e9b25bc1d911aa565d0dc02bcc16d70c36304b..b3f49c49d4412b53c72a8391fd70e7f8dbe9608b 100644 (file)
@@ -563,6 +563,7 @@ imapc_sync_begin(struct imapc_mailbox *mbox,
                return ret;
        }
 
+       i_assert(mbox->sync_view == NULL);
        i_assert(mbox->delayed_sync_trans == NULL);
        mbox->sync_view = ctx->sync_view;
        mbox->delayed_sync_view =