dovecot-2.2: dsync: Debug logging improvements and comment clari...

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 6 10:17:31 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/bf086c6f6e4a
changeset: 17890:bf086c6f6e4a
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Oct 06 13:17:00 2014 +0300
description:
dsync: Debug logging improvements and comment clarifications.

diffstat:

 src/doveadm/dsync/dsync-mailbox-import.c |  43 +++++++++++++++++++------------
 1 files changed, 26 insertions(+), 17 deletions(-)

diffs (95 lines):

diff -r d2fbe6b6c53e -r bf086c6f6e4a src/doveadm/dsync/dsync-mailbox-import.c
--- a/src/doveadm/dsync/dsync-mailbox-import.c	Mon Oct 06 13:13:04 2014 +0300
+++ b/src/doveadm/dsync/dsync-mailbox-import.c	Mon Oct 06 13:17:00 2014 +0300
@@ -1370,12 +1370,14 @@
 
 static bool
 dsync_mailbox_find_common_expunged_uid(struct dsync_mailbox_importer *importer,
-				       const struct dsync_mail_change *change)
+				       const struct dsync_mail_change *change,
+				       const char **result_r)
 {
 	const struct dsync_mail_change *local_change;
 
 	if (*change->guid == '\0') {
 		/* remote doesn't support GUIDs, can't verify expunge */
+		*result_r = "GUIDs not supported, can't verify expunge";
 		return FALSE;
 	}
 
@@ -1385,20 +1387,27 @@
 	   GUID string to 128bit GUID first. */
 	local_change = hash_table_lookup(importer->local_changes,
 					 POINTER_CAST(change->uid));
-	if (local_change == NULL || local_change->guid == NULL)
+	if (local_change == NULL || local_change->guid == NULL) {
+		*result_r = "Expunged local mail's GUID not found";
 		return FALSE;
+	}
 
 	i_assert(local_change->type == DSYNC_MAIL_CHANGE_TYPE_EXPUNGE);
 	if (dsync_mail_change_guid_equals(importer, local_change,
-					  change->guid, NULL))
+					  change->guid, NULL)) {
 		importer->last_common_uid = change->uid;
-	else if (change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE)
+		*result_r = "Expunged local mail's GUID matches remote";
+	} else if (change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE) {
 		dsync_mailbox_common_uid_found(importer);
-	else {
+		*result_r = "Expunged local mail's GUID doesn't match remote GUID";
+	} else {
 		/* GUID mismatch for two expunged mails. dsync can't update
 		   GUIDs for already expunged messages, so we can't immediately
 		   determine that the rest of the messages are a mismatch. so
 		   for now we'll just skip over this pair. */
+		*result_r = "Expunged mails' GUIDs don't match - delaying decision";
+		/* NOTE: the return value here doesn't matter, because the only
+		   caller that checks for it never reaches this code path */
 	}
 	return TRUE;
 }
@@ -1436,20 +1445,22 @@
 			*result_r = "Expunged mail not found locally";
 			return;
 		}
-		if (importer->revert_local_changes &&
-		    importer->local_uid_next > change->uid) {
+		i_assert(change->guid != NULL);
+		if (importer->local_uid_next <= change->uid) {
+			dsync_mailbox_common_uid_found(importer);
+			*result_r = "Mail's UID is above local UIDNEXT";
+		} else if (importer->revert_local_changes) {
 			dsync_mailbox_revert_missing(importer, change);
 			*result_r = "Reverting local change by deleting mailbox";
-		} else if (change->guid == NULL ||
-			 !dsync_mailbox_find_common_expunged_uid(importer, change)) {
-			/* couldn't match it for an expunged mail. use the last
-			   message with a matching GUID as the last common
+		} else if (!dsync_mailbox_find_common_expunged_uid(importer, change, result_r)) {
+			/* it's unknown if this mail existed locally and was
+			   expunged. since we don't want to lose any mails,
+			   assume that we need to preserve the mail. use the
+			   last message with a matching GUID as the last common
 			   UID. */
 			dsync_mailbox_common_uid_found(importer);
-			*result_r = "No more local mails found";
-		} else {
-			*result_r = "Mail expunged locally";
 		}
+		*result_r = t_strdup_printf("%s - No more local mails found", *result_r);
 		return;
 	}
 
@@ -1478,10 +1489,8 @@
 	    change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE) {
 		dsync_mailbox_revert_missing(importer, change);
 		*result_r = "Reverting local change by deleting mailbox";
-	} else if (dsync_mailbox_find_common_expunged_uid(importer, change)) {
-		*result_r = "Mail expunged locally";
 	} else {
-		*result_r = "Mail not found locally";
+		(void)dsync_mailbox_find_common_expunged_uid(importer, change, result_r);
 	}
 	*result_r = t_strdup_printf("%s (next local mail UID=%u)",
 				    *result_r, importer->cur_mail->uid);


More information about the dovecot-cvs mailing list