From: Timo Sirainen Date: Thu, 6 Jul 2017 08:24:35 +0000 (+0300) Subject: virtual: Avoid assert-crash if backend mailbox's have_guid lookup fails X-Git-Tag: 2.3.0.rc1~1312 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d5282594ec73c953ffb23096a2cddf373cc15f46;p=thirdparty%2Fdovecot%2Fcore.git virtual: Avoid assert-crash if backend mailbox's have_guid lookup fails The MAIL_ERROR_NOTFOUND can happen if the mailbox was already deleted. Other errors aren't expected to happen and possibly point to a bug. Fixes: Panic: file mail-storage.c: line 1831: unreached --- diff --git a/src/plugins/virtual/virtual-storage.c b/src/plugins/virtual/virtual-storage.c index 32b89ba7de..2066ea81be 100644 --- a/src/plugins/virtual/virtual-storage.c +++ b/src/plugins/virtual/virtual-storage.c @@ -554,8 +554,23 @@ static int virtual_storage_set_have_guid_flags(struct virtual_mailbox *mbox) bboxes = array_get(&mbox->backend_boxes, &count); for (i = 0; i < count; i++) { if (mailbox_get_status(bboxes[i]->box, 0, &status) < 0) { - virtual_box_copy_error(&mbox->box, bboxes[i]->box); - return -1; + const char *errstr; + enum mail_error error; + + errstr = mailbox_get_last_error(bboxes[i]->box, &error); + if (error == MAIL_ERROR_NOTFOUND) { + /* backend mailbox was just lost - skip it */ + continue; + } + /* Not expected to happen, but we can't return failure + since this could be called from + mailbox_get_open_status() and it would panic. + So just log the error and skip the mailbox. */ + mail_storage_set_critical(mbox->box.storage, + "Virtual mailbox %s: Failed to get have_guid existence for backend mailbox %s: %s", + mailbox_get_vname(&mbox->box), + mailbox_get_vname(bboxes[i]->box), errstr); + continue; } if (!status.have_guids) mbox->have_guids = FALSE;