changeset 20816:877fb5725b00

imap: If mailbox is inconsistent after syncing, don't try to sync message counts. This fixes (e.g. after doveadm force-resync): Panic: Message count decreased
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 27 Sep 2016 19:38:26 +0300
parents 4caea9d3ea33
children 75519fa6f6a5
files src/imap/imap-sync.c
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-sync.c	Sun Oct 02 14:18:35 2016 +0200
+++ b/src/imap/imap-sync.c	Tue Sep 27 19:38:26 2016 +0300
@@ -326,6 +326,13 @@
 		client_disconnect_with_error(client,
 					     "Mailbox UIDVALIDITY changed");
 	}
+	if (mailbox_is_inconsistent(ctx->box)) {
+		client_disconnect_with_error(client,
+			"IMAP session state is inconsistent, please relogin.");
+		/* we can't trust status information anymore, so don't try to
+		   sync message counts. */
+		return -1;
+	}
 	if (!ctx->no_newmail && !aborting) {
 		if (ctx->status.messages < ctx->messages_count)
 			i_panic("Message count decreased");