changeset 22339:d3dd6c5defe8

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
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 06 Jul 2017 11:24:35 +0300
parents 7a30ce5f35b6
children 06bf20f5e3ec
files src/plugins/virtual/virtual-storage.c
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/virtual/virtual-storage.c	Thu May 18 14:59:51 2017 +0300
+++ b/src/plugins/virtual/virtual-storage.c	Thu Jul 06 11:24:35 2017 +0300
@@ -554,8 +554,23 @@
 	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;