dovecot-2.0: dsync: Find changed mailboxes also based on number ...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 1 20:02:10 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/28639e01a479
changeset: 11681:28639e01a479
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 01 18:02:06 2010 +0100
description:
dsync: Find changed mailboxes also based on number of messages in them.

diffstat:

 src/dsync/dsync-brain.c                 |   7 +++
 src/dsync/dsync-data.h                  |   2 +-
 src/dsync/dsync-proxy.c                 |  13 +++++-
 src/dsync/dsync-worker-local.c          |   1 +
 src/dsync/test-dsync-brain.c            |  44 +++++++++++-----------
 src/dsync/test-dsync-proxy-server-cmd.c |   8 +++-
 6 files changed, 47 insertions(+), 28 deletions(-)

diffs (193 lines):

diff -r 49b226835cd2 -r 28639e01a479 src/dsync/dsync-brain.c
--- a/src/dsync/dsync-brain.c	Thu Jul 01 18:01:37 2010 +0100
+++ b/src/dsync/dsync-brain.c	Thu Jul 01 18:02:06 2010 +0100
@@ -562,6 +562,13 @@
 		}
 		return TRUE;
 	}
+	if (box1->message_count != box2->message_count) {
+		if (brain->verbose) {
+			i_info("%s: message_count changed %u -> %u", name,
+			       box1->message_count, box2->message_count);
+		}
+		return TRUE;
+	}
 	return FALSE;
 }
 
diff -r 49b226835cd2 -r 28639e01a479 src/dsync/dsync-data.h
--- a/src/dsync/dsync-data.h	Thu Jul 01 18:01:37 2010 +0100
+++ b/src/dsync/dsync-data.h	Thu Jul 01 18:02:06 2010 +0100
@@ -22,7 +22,7 @@
 	/* Mailbox's GUID. Full of zero with \Noselect mailboxes. */
 	mailbox_guid_t mailbox_guid;
 
-	uint32_t uid_validity, uid_next;
+	uint32_t uid_validity, uid_next, message_count;
 	uint64_t highest_modseq;
 	/* if mailbox is deleted, this is the deletion timestamp.
 	   otherwise it's the last rename timestamp. */
diff -r 49b226835cd2 -r 28639e01a479 src/dsync/dsync-proxy.c
--- a/src/dsync/dsync-proxy.c	Thu Jul 01 18:01:37 2010 +0100
+++ b/src/dsync/dsync-proxy.c	Thu Jul 01 18:02:06 2010 +0100
@@ -172,8 +172,8 @@
 
 	str_append_c(str, '\t');
 	dsync_proxy_mailbox_guid_export(str, &box->mailbox_guid);
-	str_printfa(str, "\t%u\t%u\t%llu",
-		    box->uid_validity, box->uid_next,
+	str_printfa(str, "\t%u\t%u\t%u\t%llu",
+		    box->uid_validity, box->uid_next, box->message_count,
 		    (unsigned long long)box->highest_modseq);
 	dsync_proxy_strings_export(str, &box->cache_fields);
 }
@@ -193,7 +193,8 @@
 		return -1;
 	}
 
-	/* name dir_guid mailbox_guid uid_validity uid_next highest_modseq */
+	/* name dir_guid mailbox_guid uid_validity uid_next
+	   message_count highest_modseq */
 	box_r->name = p_strdup(pool, args[i++]);
 	dsync_str_sha_to_guid(box_r->name, &box_r->name_sha1);
 
@@ -238,6 +239,12 @@
 		return -1;
 	}
 
+	box_r->message_count = strtoul(args[i++], &p, 10);
+	if (*p != '\0') {
+		*error_r = "Invalid mailbox message_count";
+		return -1;
+	}
+
 	box_r->highest_modseq = strtoull(args[i++], &p, 10);
 	if (*p != '\0') {
 		*error_r = "Invalid mailbox highest_modseq";
diff -r 49b226835cd2 -r 28639e01a479 src/dsync/dsync-worker-local.c
--- a/src/dsync/dsync-worker-local.c	Thu Jul 01 18:01:37 2010 +0100
+++ b/src/dsync/dsync-worker-local.c	Thu Jul 01 18:02:06 2010 +0100
@@ -538,6 +538,7 @@
 	       sizeof(dsync_box_r->mailbox_guid.guid));
 	dsync_box_r->uid_validity = status.uidvalidity;
 	dsync_box_r->uid_next = status.uidnext;
+	dsync_box_r->message_count = status.messages;
 	dsync_box_r->highest_modseq = status.highest_modseq;
 
 	p_clear(iter->ret_pool);
diff -r 49b226835cd2 -r 28639e01a479 src/dsync/test-dsync-brain.c
--- a/src/dsync/test-dsync-brain.c	Thu Jul 01 18:01:37 2010 +0100
+++ b/src/dsync/test-dsync-brain.c	Thu Jul 01 18:02:06 2010 +0100
@@ -111,28 +111,28 @@
 static void test_dsync_brain(void)
 {
 	static struct dsync_mailbox src_boxes[] = {
-		{ "box1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "box2", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "box3", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "box4", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "box5", '/', { { 0, } }, { { 0, } }, 1234567890, 5433, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "box6", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123124ULL, 3636, 0, ARRAY_INIT },
-		{ "boxx", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "boxd1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "boxd2", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, DSYNC_MAILBOX_FLAG_DELETED_MAILBOX, ARRAY_INIT },
-		{ NULL, 0, { { 0, } }, { { 0, } }, 0, 0, 0, 0, 0, ARRAY_INIT }
+		{ "box1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box2", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box3", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box4", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box5", '/', { { 0, } }, { { 0, } }, 1234567890, 5433, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box6", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123124ULL, 3636, 0, ARRAY_INIT },
+		{ "boxx", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "boxd1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "boxd2", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, DSYNC_MAILBOX_FLAG_DELETED_MAILBOX, ARRAY_INIT },
+		{ NULL, 0, { { 0, } }, { { 0, } }, 0, 0, 0, 0, 0, 0, ARRAY_INIT }
 	};
 	static struct dsync_mailbox dest_boxes[] = {
-		{ "box1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "box2", '/', { { 0, } }, { { 0, } }, 1234567891, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "box3", '/', { { 0, } }, { { 0, } }, 1234567890, 5433, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "box4", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123124ULL, 3636, 0, ARRAY_INIT },
-		{ "box5", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "box6", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "boxy", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ "boxd1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, DSYNC_MAILBOX_FLAG_DELETED_MAILBOX, ARRAY_INIT },
-		{ "boxd2", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 3636, 0, ARRAY_INIT },
-		{ NULL, 0, { { 0, } }, { { 0, } }, 0, 0, 0, 0, 0, ARRAY_INIT }
+		{ "box1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box2", '/', { { 0, } }, { { 0, } }, 1234567891, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box3", '/', { { 0, } }, { { 0, } }, 1234567890, 5433, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box4", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123124ULL, 3636, 0, ARRAY_INIT },
+		{ "box5", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box6", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "boxy", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "boxd1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, DSYNC_MAILBOX_FLAG_DELETED_MAILBOX, ARRAY_INIT },
+		{ "boxd2", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ NULL, 0, { { 0, } }, { { 0, } }, 0, 0, 0, 0, 0, 0, ARRAY_INIT }
 	};
 	struct dsync_brain *brain;
 	struct dsync_worker *src_worker, *dest_worker;
@@ -221,8 +221,8 @@
 static void test_dsync_brain_full(void)
 {
 	static struct dsync_mailbox boxes[] = {
-		{ "box1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 123123123123ULL, 2352, 0, ARRAY_INIT },
-		{ NULL, 0, { { 0, } }, { { 0, } }, 0, 0, 0, 0, 0, ARRAY_INIT }
+		{ "box1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 2352, 0, ARRAY_INIT },
+		{ NULL, 0, { { 0, } }, { { 0, } }, 0, 0, 0, 0, 0, 0, ARRAY_INIT }
 	};
 	struct dsync_brain *brain;
 	struct dsync_worker *src_worker, *dest_worker;
diff -r 49b226835cd2 -r 28639e01a479 src/dsync/test-dsync-proxy-server-cmd.c
--- a/src/dsync/test-dsync-proxy-server-cmd.c	Thu Jul 01 18:01:37 2010 +0100
+++ b/src/dsync/test-dsync-proxy-server-cmd.c	Thu Jul 01 18:02:06 2010 +0100
@@ -90,6 +90,7 @@
 	memcpy(box.mailbox_guid.guid, test_mailbox_guid1, MAIL_GUID_128_SIZE);
 	box.uid_validity = 4275878552;
 	box.uid_next = 4023233417;
+	box.message_count = 4525;
 	box.highest_modseq = 18080787909545915012ULL;
 	test_worker->box_iter.next_box = &box;
 
@@ -99,6 +100,7 @@
 			   TEST_MAILBOX_GUID1"\t"
 			   "4275878552\t"
 			   "4023233417\t"
+			   "4525\t"
 			   "18080787909545915012\n") == 0);
 	out_clear();
 
@@ -229,7 +231,7 @@
 
 	test_assert(run_cmd("BOX-CREATE", "selectable", "?",
 			    "61", "2", TEST_MAILBOX_GUID2, "1234567890", "9876",
-			    "28427847284728", NULL) == 1);
+			    "4610", "28427847284728", NULL) == 1);
 	test_assert(test_dsync_worker_next_box_event(test_worker, &event));
 	test_assert(event.type == LAST_BOX_TYPE_CREATE);
 	test_assert(strcmp(event.box.name, "selectable") == 0);
@@ -238,6 +240,7 @@
 	test_assert(event.box.flags == 2);
 	test_assert(event.box.uid_validity == 1234567890);
 	test_assert(event.box.uid_next == 9876);
+	test_assert(event.box.message_count == 4610);
 	test_assert(event.box.highest_modseq == 28427847284728);
 	test_assert(event.box.last_change == 61);
 
@@ -296,7 +299,7 @@
 
 	test_assert(run_cmd("BOX-UPDATE", "updated", "/",
 			    "53", "2", TEST_MAILBOX_GUID1, "34343", "22",
-			    "2238427847284728", NULL) == 1);
+			    "58293", "2238427847284728", NULL) == 1);
 	test_assert(test_dsync_worker_next_box_event(test_worker, &event));
 	test_assert(event.type == LAST_BOX_TYPE_UPDATE);
 	test_assert(strcmp(event.box.name, "updated") == 0);
@@ -305,6 +308,7 @@
 	test_assert(event.box.flags == DSYNC_MAILBOX_FLAG_DELETED_MAILBOX);
 	test_assert(event.box.uid_validity == 34343);
 	test_assert(event.box.uid_next == 22);
+	test_assert(event.box.message_count == 58293);
 	test_assert(event.box.highest_modseq == 2238427847284728);
 	test_assert(event.box.last_change == 53);
 


More information about the dovecot-cvs mailing list