changeset 22048:6946011b3b0a

imapc: If initial SELECT fails, don't resend it twice on reconnect.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 18 May 2017 18:01:27 +0300
parents ec84babd5727
children c24c32983eae
files src/lib-storage/index/imapc/imapc-storage.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-storage.c	Thu May 18 17:36:27 2017 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.c	Thu May 18 18:01:27 2017 +0300
@@ -564,12 +564,21 @@
 	struct imapc_command *cmd;
 
 	/* we're reconnecting and need to reopen the mailbox */
-	mbox->initial_sync_done = FALSE;
-	mbox->selecting = TRUE;
 	mbox->prev_skipped_rseq = 0;
 	mbox->prev_skipped_uid = 0;
 	imapc_msgmap_reset(imapc_client_mailbox_get_msgmap(mbox->client_box));
 
+	if (mbox->selecting) {
+		/* We reconnected during the initial SELECT/EXAMINE. It'll be
+		   automatically resent by lib-imap-client, so we don't need to
+		   send it again here. */
+		i_assert(!mbox->initial_sync_done);
+		return;
+	}
+
+	mbox->initial_sync_done = FALSE;
+	mbox->selecting = TRUE;
+
 	cmd = imapc_client_mailbox_cmd(mbox->client_box,
 				       imapc_mailbox_reopen_callback, mbox);
 	imapc_command_set_flags(cmd, IMAPC_COMMAND_FLAG_SELECT);