dovecot-2.1: imapc: Handle disconnection better when fetching a ...

dovecot at dovecot.org dovecot at dovecot.org
Tue Sep 20 11:53:19 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/25f9856be51e
changeset: 13517:25f9856be51e
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Sep 20 11:53:02 2011 +0300
description:
imapc: Handle disconnection better when fetching a mail.

diffstat:

 src/lib-storage/index/imapc/imapc-mail.c |  32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diffs (56 lines):

diff -r 7d9163ce4253 -r 25f9856be51e src/lib-storage/index/imapc/imapc-mail.c
--- a/src/lib-storage/index/imapc/imapc-mail.c	Mon Sep 19 18:41:36 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-mail.c	Tue Sep 20 11:53:02 2011 +0300
@@ -51,6 +51,22 @@
 	return !imapc_msgmap_uid_to_rseq(msgmap, _mail->uid, &rseq);
 }
 
+static void imapc_mail_failed(struct mail *mail, const char *field)
+{
+	struct imapc_mailbox *mbox = (struct imapc_mailbox *)mail->box;
+
+	if (mail->expunged || imapc_mail_is_expunged(mail))
+		mail_set_expunged(mail);
+	else if (!imapc_client_mailbox_is_connected(mbox->client_box)) {
+		/* we've already logged a disconnection error */
+		mail_storage_set_internal_error(mail->box->storage);
+	} else {
+		mail_storage_set_critical(mail->box->storage,
+			"imapc: Remote server didn't send %s for UID %u",
+			field, mail->uid);
+	}
+}
+
 static int imapc_mail_get_received_date(struct mail *_mail, time_t *date_r)
 {
 	struct index_mail *mail = (struct index_mail *)_mail;
@@ -63,13 +79,7 @@
 		if (imapc_mail_fetch(_mail, MAIL_FETCH_RECEIVED_DATE) < 0)
 			return -1;
 		if (data->received_date == (time_t)-1) {
-			if (_mail->expunged || imapc_mail_is_expunged(_mail))
-				mail_set_expunged(_mail);
-			else {
-				mail_storage_set_critical(_mail->box->storage,
-					"imapc: Remote server didn't send "
-					"INTERNALDATE for UID %u", _mail->uid);
-			}
+			imapc_mail_failed(_mail, "INTERNALDATE");
 			return -1;
 		}
 	}
@@ -140,13 +150,7 @@
 			return -1;
 
 		if (data->stream == NULL) {
-			if (_mail->expunged || imapc_mail_is_expunged(_mail))
-				mail_set_expunged(_mail);
-			else {
-				mail_storage_set_critical(_mail->box->storage,
-					"imapc: Remote server didn't send "
-					"BODY[] for UID %u", _mail->uid);
-			}
+			imapc_mail_failed(_mail, "BODY[]");
 			return -1;
 		}
 	}


More information about the dovecot-cvs mailing list