dovecot-2.2: dsync: Added debug logging for attribute importing

dovecot at dovecot.org dovecot at dovecot.org
Sat Oct 25 19:54:35 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/4155055df7a9
changeset: 18018:4155055df7a9
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Oct 25 22:53:35 2014 +0300
description:
dsync: Added debug logging for attribute importing

diffstat:

 src/doveadm/dsync/dsync-mailbox-import.c |  33 ++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 4 deletions(-)

diffs (92 lines):

diff -r 096706c5b616 -r 4155055df7a9 src/doveadm/dsync/dsync-mailbox-import.c
--- a/src/doveadm/dsync/dsync-mailbox-import.c	Sat Oct 25 06:57:25 2014 +0300
+++ b/src/doveadm/dsync/dsync-mailbox-import.c	Sat Oct 25 22:53:35 2014 +0300
@@ -370,8 +370,10 @@
 	return dsync_attributes_cmp_values(attr, local_attr, cmp_r);
 }
 
-int dsync_mailbox_import_attribute(struct dsync_mailbox_importer *importer,
-				   const struct dsync_mailbox_attribute *attr)
+static int
+dsync_mailbox_import_attribute_real(struct dsync_mailbox_importer *importer,
+				    const struct dsync_mailbox_attribute *attr,
+				    const char **result_r)
 {
 	struct dsync_mailbox_attribute *local_attr;
 	struct mail_attribute_value value;
@@ -386,25 +388,31 @@
 	if (attr->deleted &&
 	    (local_attr == NULL || !DSYNC_ATTR_HAS_VALUE(local_attr))) {
 		/* attribute doesn't exist on either side -> ignore */
+		*result_r = "Nonexistent in both sides";
 		return 0;
 	}
 	if (local_attr == NULL) {
 		/* we haven't seen this locally -> use whatever remote has */
+		*result_r = "Nonexistent locally";
 	} else if (local_attr->modseq <= importer->last_common_modseq &&
 		   attr->modseq > importer->last_common_modseq &&
 		   importer->last_common_modseq > 0) {
 		/* we're doing incremental syncing, and we can see that the
 		   attribute was changed remotely, but not locally -> use it */
+		*result_r = "Changed remotely";
 	} else if (local_attr->modseq > importer->last_common_modseq &&
 		   attr->modseq <= importer->last_common_modseq &&
 		   importer->last_common_modseq > 0) {
 		/* we're doing incremental syncing, and we can see that the
 		   attribute was changed locally, but not remotely -> ignore */
+		*result_r = "Changed locally";
 		ignore = TRUE;
 	} else if (attr->last_change > local_attr->last_change) {
 		/* remote has a newer timestamp -> use it */
+		*result_r = "Remote has newer timestamp";
 	} else if (attr->last_change < local_attr->last_change) {
 		/* remote has an older timestamp -> ignore */
+		*result_r = "Local has newer timestamp";
 		ignore = TRUE;
 	} else {
 		/* the timestamps are the same. now we're down to guessing
@@ -418,17 +426,22 @@
 		}
 		if (cmp == 0) {
 			/* identical scripts */
+			*result_r = "Unchanged value";
 			return 0;
 		}
 
 		if (attr->modseq > local_attr->modseq) {
 			/* remote has a higher modseq -> use it */
+			*result_r = "Remote has newer modseq";
 		} else if (attr->modseq < local_attr->modseq) {
 			/* remote has an older modseq -> ignore */
+			*result_r = "Local has newer modseq";
 			ignore = TRUE;
+		} else if (cmp < 0) {
+			ignore = TRUE;
+			*result_r = "Value changed, but unknown which is newer - picking local";
 		} else {
-			if (cmp < 0)
-				ignore = TRUE;
+			*result_r = "Value changed, but unknown which is newer - picking remote";
 		}
 	}
 	if (ignore) {
@@ -454,6 +467,18 @@
 	return 0;
 }
 
+int dsync_mailbox_import_attribute(struct dsync_mailbox_importer *importer,
+				   const struct dsync_mailbox_attribute *attr)
+{
+	const char *result;
+	int ret;
+
+	ret = dsync_mailbox_import_attribute_real(importer, attr, &result);
+	imp_debug(importer, "Import attribute %s: %s", attr->key,
+		  ret < 0 ? "failed" : result);
+	return ret;
+}
+
 static void dsync_mail_error(struct dsync_mailbox_importer *importer,
 			     struct mail *mail, const char *field)
 {


More information about the dovecot-cvs mailing list