dovecot-2.2: dsync: If mailbox export deinit failed, the failure...

dovecot at dovecot.org dovecot at dovecot.org
Wed Aug 26 13:06:17 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/adb69a13bc66
changeset: 19013:adb69a13bc66
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 26 15:05:06 2015 +0200
description:
dsync: If mailbox export deinit failed, the failure state may not have reached mailbox importer.
The "end of list" was sent to the importer side dsync before export noticed
the failure. This could have caused import to complain about missing mails.

diffstat:

 src/doveadm/dsync/dsync-brain-mails.c |  25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diffs (62 lines):

diff -r 156aed1fc0fc -r adb69a13bc66 src/doveadm/dsync/dsync-brain-mails.c
--- a/src/doveadm/dsync/dsync-brain-mails.c	Wed Aug 26 13:38:52 2015 +0200
+++ b/src/doveadm/dsync/dsync-brain-mails.c	Wed Aug 26 15:05:06 2015 +0200
@@ -190,25 +190,12 @@
 static void dsync_brain_sync_half_finished(struct dsync_brain *brain)
 {
 	struct dsync_mailbox_state state;
-	const char *errstr;
-	enum mail_error error;
 
 	if (brain->box_recv_state < DSYNC_BOX_STATE_RECV_LAST_COMMON ||
 	    brain->box_send_state < DSYNC_BOX_STATE_RECV_LAST_COMMON)
 		return;
 
 	/* finished with this mailbox */
-	if (brain->box_exporter != NULL) {
-		if (dsync_mailbox_export_deinit(&brain->box_exporter,
-						&errstr, &error) < 0) {
-			i_error("Exporting mailbox %s failed: %s",
-				mailbox_get_vname(brain->box), errstr);
-			brain->mail_error = error;
-			brain->failed = TRUE;
-			return;
-		}
-	}
-
 	memset(&state, 0, sizeof(state));
 	memcpy(state.mailbox_guid, brain->local_dsync_box.mailbox_guid,
 	       sizeof(state.mailbox_guid));
@@ -249,6 +236,7 @@
 		return FALSE;
 	if (ret == DSYNC_IBC_RECV_RET_FINISHED) {
 		brain->box_recv_state = DSYNC_BOX_STATE_RECV_LAST_COMMON;
+		i_assert(brain->box_exporter == NULL);
 		dsync_brain_sync_half_finished(brain);
 		return TRUE;
 	}
@@ -265,6 +253,8 @@
 static bool dsync_brain_send_mail(struct dsync_brain *brain)
 {
 	const struct dsync_mail *mail;
+	const char *errstr;
+	enum mail_error error;
 
 	if (brain->mail_requests &&
 	    brain->box_recv_state < DSYNC_BOX_STATE_MAILS) {
@@ -280,6 +270,15 @@
 			return TRUE;
 	}
 
+	if (dsync_mailbox_export_deinit(&brain->box_exporter,
+					&errstr, &error) < 0) {
+		i_error("Exporting mailbox %s failed: %s",
+			mailbox_get_vname(brain->box), errstr);
+		brain->mail_error = error;
+		brain->failed = TRUE;
+		return TRUE;
+	}
+
 	brain->box_send_state = DSYNC_BOX_STATE_DONE;
 	dsync_brain_send_end_of_list(brain, DSYNC_IBC_EOL_MAILS);
 


More information about the dovecot-cvs mailing list