]> 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 <timo.sirainen@dovecot.fi>
Wed, 19 Jul 2017 09:43:35 +0000 (12:43 +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 c8f92565bd0952c14203b7974d483fcdde2a5583..d0f45418dc84f5422342752d87527229f1b50874 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 3cd455c84a73ebabde0def499c95a0f88fc89f54..5e9ef8f2b85a6eae5a460de42ae71a1f92a8dd00 100644 (file)
@@ -114,6 +114,7 @@ struct virtual_backend_box {
        unsigned int uids_nonsorted:1;
        unsigned int search_args_initialized:1;
        unsigned int deleted:1;
+       unsigned int notify_changes_started:1; /* if the box was opened for notify_changes */
 };
 ARRAY_DEFINE_TYPE(virtual_backend_box, struct virtual_backend_box *);