dovecot-2.2: dsync: Don't wrongly log errors about missing messa...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jan 9 05:43:21 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/cc77431b09b4
changeset: 15611:cc77431b09b4
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jan 09 05:42:03 2013 +0200
description:
dsync: Don't wrongly log errors about missing message bodies.
Also added some debug logging related to it.

diffstat:

 src/doveadm/dsync/dsync-brain-mailbox.c  |   2 +
 src/doveadm/dsync/dsync-mailbox-import.c |  46 ++++++++++++++++++++-----------
 src/doveadm/dsync/dsync-mailbox-import.h |   3 +-
 3 files changed, 34 insertions(+), 17 deletions(-)

diffs (125 lines):

diff -r 3d3625d18231 -r cc77431b09b4 src/doveadm/dsync/dsync-brain-mailbox.c
--- a/src/doveadm/dsync/dsync-brain-mailbox.c	Wed Jan 09 05:28:58 2013 +0200
+++ b/src/doveadm/dsync/dsync-brain-mailbox.c	Wed Jan 09 05:42:03 2013 +0200
@@ -209,6 +209,8 @@
 		import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS;
 	if (brain->backup_recv)
 		import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES;
+	if (brain->debug)
+		import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_DEBUG;
 
 	brain->box_importer = brain->backup_send ? NULL :
 		dsync_mailbox_import_init(brain->box, brain->log_scan,
diff -r 3d3625d18231 -r cc77431b09b4 src/doveadm/dsync/dsync-mailbox-import.c
--- a/src/doveadm/dsync/dsync-mailbox-import.c	Wed Jan 09 05:28:58 2013 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-import.c	Wed Jan 09 05:42:03 2013 +0200
@@ -73,6 +73,7 @@
 	uint64_t local_initial_highestmodseq, local_initial_highestpvtmodseq;
 
 	unsigned int failed:1;
+	unsigned int debug:1;
 	unsigned int last_common_uid_found:1;
 	unsigned int cur_uid_has_change:1;
 	unsigned int cur_mail_saved:1;
@@ -165,6 +166,7 @@
 		(flags & DSYNC_MAILBOX_IMPORT_FLAG_MASTER_BRAIN) != 0;
 	importer->revert_local_changes =
 		(flags & DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES) != 0;
+	importer->debug = (flags & DSYNC_MAILBOX_IMPORT_FLAG_DEBUG) != 0;
 
 	mailbox_get_open_status(importer->box, STATUS_UIDNEXT |
 				STATUS_HIGHESTMODSEQ | STATUS_HIGHESTPVTMODSEQ,
@@ -1489,20 +1491,26 @@
 }
 
 static unsigned int
-dsync_mailbox_import_count_missing_guid_imports(HASH_TABLE_TYPE(guid_new_mail) imports)
+dsync_mailbox_import_count_missing_guid_imports(struct dsync_mailbox_importer *importer)
 {
 	struct hash_iterate_context *iter;
 	const char *key;
 	struct importer_new_mail *mail;
 	unsigned int msgs_left = 0;
 
-	iter = hash_table_iterate_init(imports);
-	while (hash_table_iterate(iter, imports, &key, &mail)) {
+	iter = hash_table_iterate_init(importer->import_guids);
+	while (hash_table_iterate(iter, importer->import_guids, &key, &mail)) {
 		for (; mail != NULL; mail = mail->next) {
-			if (!mail->uid_in_local) {
-				msgs_left++;
-				break;
+			if (mail->uid_in_local || mail->skip)
+				continue;
+
+			if (importer->debug) {
+				i_debug("Mailbox %s: Missing mail GUID=%s (UID=%u)",
+					mailbox_get_vname(importer->box),
+					mail->guid, mail->uid);
 			}
+			msgs_left++;
+			break;
 		}
 	}
 	hash_table_iterate_deinit(&iter);
@@ -1510,20 +1518,26 @@
 }
 
 static unsigned int
-dsync_mailbox_import_count_missing_uid_imports(HASH_TABLE_TYPE(uid_new_mail) imports)
+dsync_mailbox_import_count_missing_uid_imports(struct dsync_mailbox_importer *importer)
 {
 	struct hash_iterate_context *iter;
 	void *key;
 	struct importer_new_mail *mail;
 	unsigned int msgs_left = 0;
 
-	iter = hash_table_iterate_init(imports);
-	while (hash_table_iterate(iter, imports, &key, &mail)) {
+	iter = hash_table_iterate_init(importer->import_uids);
+	while (hash_table_iterate(iter, importer->import_uids, &key, &mail)) {
 		for (; mail != NULL; mail = mail->next) {
-			if (!mail->uid_in_local) {
-				msgs_left++;
-				break;
+			if (mail->uid_in_local || mail->skip)
+				continue;
+
+			if (importer->debug) {
+				i_debug("Mailbox %s: Missing mail UID=%u",
+					mailbox_get_vname(importer->box),
+					mail->uid);
 			}
+			msgs_left++;
+			break;
 		}
 	}
 	hash_table_iterate_deinit(&iter);
@@ -1546,10 +1560,10 @@
 	if (!importer->new_uids_assigned)
 		dsync_mailbox_import_assign_new_uids(importer);
 
-	msgs_left =
-		dsync_mailbox_import_count_missing_guid_imports(importer->import_guids) +
-		dsync_mailbox_import_count_missing_uid_imports(importer->import_uids);
-	if (!importer->failed && msgs_left > 0) {
+	msgs_left = importer->failed ? 0 :
+		dsync_mailbox_import_count_missing_guid_imports(importer) +
+		dsync_mailbox_import_count_missing_uid_imports(importer);
+	if (msgs_left > 0) {
 		i_error("%s: Remote didn't send %u expected message bodies",
 			mailbox_get_vname(importer->box), msgs_left);
 	}
diff -r 3d3625d18231 -r cc77431b09b4 src/doveadm/dsync/dsync-mailbox-import.h
--- a/src/doveadm/dsync/dsync-mailbox-import.h	Wed Jan 09 05:28:58 2013 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-import.h	Wed Jan 09 05:42:03 2013 +0200
@@ -5,7 +5,8 @@
 	DSYNC_MAILBOX_IMPORT_FLAG_MASTER_BRAIN		= 0x01,
 	DSYNC_MAILBOX_IMPORT_FLAG_WANT_MAIL_REQUESTS	= 0x02,
 	DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS	= 0x04,
-	DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES	= 0x08
+	DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES	= 0x08,
+	DSYNC_MAILBOX_IMPORT_FLAG_DEBUG			= 0x10
 };
 
 struct mailbox;


More information about the dovecot-cvs mailing list