]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
virtual: Stop notifications only if they were started
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 18 Jul 2017 18:04:47 +0000 (21:04 +0300)
committerTimo Sirainen <tss@dovecot.fi>
Wed, 19 Jul 2017 09:15:54 +0000 (12:15 +0300)
Fixes Panic: file mail-storage.c: line 1950: assertion failed: (box->opened)

src/plugins/virtual/virtual-storage.c
src/plugins/virtual/virtual-storage.h

index 10ad76463ab2091059a8b41990f027b1905cf989..b96c53b0a32bf2edb9508b89be99895334ced090 100644 (file)
@@ -426,6 +426,12 @@ void virtual_backend_box_close(struct virtual_mailbox *mbox,
        DLLIST2_REMOVE_FULL(&mbox->open_backend_boxes_head,
                            &mbox->open_backend_boxes_tail, bbox,
                            prev_open, next_open);
+
+       /* stop receiving notifications */
+       if (bbox->notify_changes_started)
+               mailbox_notify_changes_stop(bbox->box);
+       bbox->notify_changes_started = FALSE;
+
        mailbox_close(bbox->box);
 }
 
@@ -693,7 +699,10 @@ static void virtual_notify_changes(struct mailbox *box)
 
        if (box->notify_callback == NULL) {
                array_foreach_modifiable(&mbox->backend_boxes, bboxp) {
-                       mailbox_notify_changes_stop((*bboxp)->box);
+                       if ((*bboxp)->notify_changes_started) {
+                               mailbox_notify_changes_stop((*bboxp)->box);
+                               (*bboxp)->notify_changes_started = FALSE;
+                       }
                        if ((*bboxp)->notify != NULL)
                                mailbox_list_notify_deinit(&(*bboxp)->notify);
                }
@@ -717,6 +726,7 @@ static void virtual_notify_changes(struct mailbox *box)
                }
                mailbox_notify_changes((*bboxp)->box,
                                       virtual_notify_callback, box);
+               (*bboxp)->notify_changes_started = TRUE;
        }
 }
 
index fb811ec388bb4c3289ede3606626001be4dcc803..38c0dc8f49d67303527d4f99ed8d5aa6f5d62950 100644 (file)
@@ -114,6 +114,7 @@ struct virtual_backend_box {
        bool uids_nonsorted:1;
        bool search_args_initialized:1;
        bool deleted:1;
+       bool notify_changes_started:1; /* if the box was opened for notify_changes */
 };
 ARRAY_DEFINE_TYPE(virtual_backend_box, struct virtual_backend_box *);