changeset 19985:fdbd96c26d2d

imapc: If we get disconnected during SELECT/EXAMINE, retry it once. This seems to be happening especially with dsync migrations from IMAP servers with small timeouts. The initial dsync run opens imapc connection early to do a LIST + SELECT the first mailbox, but then dsync may spend a while creating all the local mailboxes before it continues using the imapc connection.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 05 Apr 2016 19:59:18 +0300
parents 5ea46ed8c156
children 7d35ad891361
files src/lib-imap-client/imapc-client.c src/lib-storage/index/imapc/imapc-storage.c
diffstat 2 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap-client/imapc-client.c	Tue Apr 05 16:26:08 2016 +0300
+++ b/src/lib-imap-client/imapc-client.c	Tue Apr 05 19:59:18 2016 +0300
@@ -277,6 +277,9 @@
 	conn->box = box;
 	box->conn = conn->conn;
 	box->msgmap = imapc_msgmap_init();
+	/* if we get disconnected before the SELECT is finished, allow
+	   one reconnect retry. */
+	box->reconnect_ok = TRUE;
 	return box;
 }
 
--- a/src/lib-storage/index/imapc/imapc-storage.c	Tue Apr 05 16:26:08 2016 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.c	Tue Apr 05 19:59:18 2016 +0300
@@ -564,7 +564,8 @@
 	ctx.ret = -2;
 	cmd = imapc_client_mailbox_cmd(mbox->client_box,
 				       imapc_mailbox_open_callback, &ctx);
-	imapc_command_set_flags(cmd, IMAPC_COMMAND_FLAG_SELECT);
+	imapc_command_set_flags(cmd, IMAPC_COMMAND_FLAG_SELECT |
+				IMAPC_COMMAND_FLAG_RETRIABLE);
 	if (imapc_mailbox_want_examine(mbox)) {
 		imapc_command_sendf(cmd, "EXAMINE %s",
 			imapc_mailbox_get_remote_name(mbox));