From: Aki Tuomi Date: Tue, 18 Jul 2017 18:04:47 +0000 (+0300) Subject: virtual: Stop notifications only if they were started X-Git-Tag: 2.2.32.rc1~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fd994bf5b6dfad174fe634f6509ef53cf95e0685;p=thirdparty%2Fdovecot%2Fcore.git virtual: Stop notifications only if they were started Fixes Panic: file mail-storage.c: line 1950: assertion failed: (box->opened) --- diff --git a/src/plugins/virtual/virtual-storage.c b/src/plugins/virtual/virtual-storage.c index c8f92565bd..d0f45418dc 100644 --- a/src/plugins/virtual/virtual-storage.c +++ b/src/plugins/virtual/virtual-storage.c @@ -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; } } diff --git a/src/plugins/virtual/virtual-storage.h b/src/plugins/virtual/virtual-storage.h index 3cd455c84a..5e9ef8f2b8 100644 --- a/src/plugins/virtual/virtual-storage.h +++ b/src/plugins/virtual/virtual-storage.h @@ -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 *);