From: Timo Sirainen Date: Fri, 24 Oct 2014 23:13:36 +0000 (+0300) Subject: virtual plugin: Fixed assert-crash when backend mailbox was auto-closed while it... X-Git-Tag: 2.2.15~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ce930f99c6a78f2c74b00df1ad2337095978a9db;p=thirdparty%2Fdovecot%2Fcore.git virtual plugin: Fixed assert-crash when backend mailbox was auto-closed while it had pending expunges. --- diff --git a/src/plugins/virtual/virtual-storage.c b/src/plugins/virtual/virtual-storage.c index 1317323882..fa0297ea60 100644 --- a/src/plugins/virtual/virtual-storage.c +++ b/src/plugins/virtual/virtual-storage.c @@ -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); diff --git a/src/plugins/virtual/virtual-sync.c b/src/plugins/virtual/virtual-sync.c index 13cac03fce..ea199ce29f 100644 --- a/src/plugins/virtual/virtual-sync.c +++ b/src/plugins/virtual/virtual-sync.c @@ -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()