dovecot-2.0: dsync: Preserve \Recent flags state (instead of set...

dovecot at dovecot.org dovecot at dovecot.org
Wed Mar 16 17:47:29 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/ad393de782ce
changeset: 12682:ad393de782ce
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Mar 16 17:46:29 2011 +0200
description:
dsync: Preserve \Recent flags state (instead of setting everything \Recent).

diffstat:

 src/dsync/dsync-brain.c                 |   1 +
 src/dsync/dsync-data.h                  |   2 +-
 src/dsync/dsync-proxy.c                 |  11 ++++-
 src/dsync/dsync-worker-local.c          |   5 ++-
 src/dsync/test-dsync-brain.c            |  44 +++++++++++-----------
 src/dsync/test-dsync-proxy-server-cmd.c |  10 +++-
 6 files changed, 44 insertions(+), 29 deletions(-)

diffs (199 lines):

diff -r 08e4c5d0dc9b -r ad393de782ce src/dsync/dsync-brain.c
--- a/src/dsync/dsync-brain.c	Wed Mar 16 17:42:42 2011 +0200
+++ b/src/dsync/dsync-brain.c	Wed Mar 16 17:46:29 2011 +0200
@@ -290,6 +290,7 @@
 	case DSYNC_BRAIN_MAILBOX_ACTION_CREATE:
 		new_box = *action_box;
 		new_box.uid_next = action_box->uid_validity == 0 ? 0 : 1;
+		new_box.first_recent_uid = 0;
 		new_box.highest_modseq = 0;
 		dsync_worker_create_mailbox(action_worker, &new_box);
 		break;
diff -r 08e4c5d0dc9b -r ad393de782ce src/dsync/dsync-data.h
--- a/src/dsync/dsync-data.h	Wed Mar 16 17:42:42 2011 +0200
+++ b/src/dsync/dsync-data.h	Wed Mar 16 17:46:29 2011 +0200
@@ -22,7 +22,7 @@
 	/* Mailbox's GUID. Full of zero with \Noselect mailboxes. */
 	mailbox_guid_t mailbox_guid;
 
-	uint32_t uid_validity, uid_next, message_count;
+	uint32_t uid_validity, uid_next, message_count, first_recent_uid;
 	uint64_t highest_modseq;
 	/* if mailbox is deleted, this is the deletion timestamp.
 	   otherwise it's the last rename timestamp. */
diff -r 08e4c5d0dc9b -r ad393de782ce src/dsync/dsync-proxy.c
--- a/src/dsync/dsync-proxy.c	Wed Mar 16 17:42:42 2011 +0200
+++ b/src/dsync/dsync-proxy.c	Wed Mar 16 17:46:29 2011 +0200
@@ -174,9 +174,10 @@
 
 	str_append_c(str, '\t');
 	dsync_proxy_mailbox_guid_export(str, &box->mailbox_guid);
-	str_printfa(str, "\t%u\t%u\t%u\t%llu",
+	str_printfa(str, "\t%u\t%u\t%u\t%llu\t%u",
 		    box->uid_validity, box->uid_next, box->message_count,
-		    (unsigned long long)box->highest_modseq);
+		    (unsigned long long)box->highest_modseq,
+		    box->first_recent_uid);
 	dsync_proxy_strings_export(str, &box->cache_fields);
 }
 
@@ -261,6 +262,12 @@
 		return -1;
 	}
 
+	box_r->first_recent_uid = strtoul(args[i++], &p, 10);
+	if (*p != '\0') {
+		*error_r = "Invalid mailbox first_recent_uid";
+		return -1;
+	}
+
 	args += i;
 	count -= i;
 	p_array_init(&box_r->cache_fields, pool, count + 1);
diff -r 08e4c5d0dc9b -r ad393de782ce src/dsync/dsync-worker-local.c
--- a/src/dsync/dsync-worker-local.c	Wed Mar 16 17:42:42 2011 +0200
+++ b/src/dsync/dsync-worker-local.c	Wed Mar 16 17:46:29 2011 +0200
@@ -566,7 +566,8 @@
 	}
 
 	mailbox_get_status(box, STATUS_UIDNEXT | STATUS_UIDVALIDITY |
-			   STATUS_HIGHESTMODSEQ | STATUS_CACHE_FIELDS, &status);
+			   STATUS_HIGHESTMODSEQ | STATUS_CACHE_FIELDS |
+			   STATUS_FIRST_RECENT_UID, &status);
 
 	change = hash_table_lookup(worker->mailbox_changes_hash, mailbox_guid);
 	if (change != NULL) {
@@ -579,6 +580,7 @@
 	dsync_box_r->uid_validity = status.uidvalidity;
 	dsync_box_r->uid_next = status.uidnext;
 	dsync_box_r->message_count = status.messages;
+	dsync_box_r->first_recent_uid = status.first_recent_uid;
 	dsync_box_r->highest_modseq = status.highest_modseq;
 
 	p_clear(iter->ret_pool);
@@ -1030,6 +1032,7 @@
 	       sizeof(update_r->mailbox_guid));
 	update_r->uid_validity = dsync_box->uid_validity;
 	update_r->min_next_uid = dsync_box->uid_next;
+	update_r->min_first_recent_uid = dsync_box->first_recent_uid;
 	update_r->min_highest_modseq = dsync_box->highest_modseq;
 }
 
diff -r 08e4c5d0dc9b -r ad393de782ce src/dsync/test-dsync-brain.c
--- a/src/dsync/test-dsync-brain.c	Wed Mar 16 17:42:42 2011 +0200
+++ b/src/dsync/test-dsync-brain.c	Wed Mar 16 17:46:29 2011 +0200
@@ -111,28 +111,28 @@
 static void test_dsync_brain(void)
 {
 	static struct dsync_mailbox src_boxes[] = {
-		{ "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 }
+		{ "box1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box2", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box3", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box4", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box5", '/', { { 0, } }, { { 0, } }, 1234567890, 5433, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box6", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123124ULL, 3636, 0, ARRAY_INIT },
+		{ "boxx", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "boxd1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "boxd2", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, DSYNC_MAILBOX_FLAG_DELETED_MAILBOX, ARRAY_INIT },
+		{ NULL, 0, { { 0, } }, { { 0, } }, 0, 0, 0, 0, 0, 0, 0, ARRAY_INIT }
 	};
 	static struct dsync_mailbox dest_boxes[] = {
-		{ "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 }
+		{ "box1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box2", '/', { { 0, } }, { { 0, } }, 1234567891, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box3", '/', { { 0, } }, { { 0, } }, 1234567890, 5433, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box4", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123124ULL, 3636, 0, ARRAY_INIT },
+		{ "box5", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "box6", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "boxy", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ "boxd1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, DSYNC_MAILBOX_FLAG_DELETED_MAILBOX, ARRAY_INIT },
+		{ "boxd2", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 3636, 0, ARRAY_INIT },
+		{ NULL, 0, { { 0, } }, { { 0, } }, 0, 0, 0, 0, 0, 0, 0, ARRAY_INIT }
 	};
 	struct dsync_brain *brain;
 	struct dsync_worker *src_worker, *dest_worker;
@@ -225,8 +225,8 @@
 static void test_dsync_brain_full(void)
 {
 	static struct dsync_mailbox boxes[] = {
-		{ "box1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 123123123123ULL, 2352, 0, ARRAY_INIT },
-		{ NULL, 0, { { 0, } }, { { 0, } }, 0, 0, 0, 0, 0, 0, ARRAY_INIT }
+		{ "box1", '/', { { 0, } }, { { 0, } }, 1234567890, 5432, 0, 1, 123123123123ULL, 2352, 0, ARRAY_INIT },
+		{ NULL, 0, { { 0, } }, { { 0, } }, 0, 0, 0, 0, 0, 0, 0, ARRAY_INIT }
 	};
 	struct dsync_brain *brain;
 	struct dsync_worker *src_worker, *dest_worker;
diff -r 08e4c5d0dc9b -r ad393de782ce src/dsync/test-dsync-proxy-server-cmd.c
--- a/src/dsync/test-dsync-proxy-server-cmd.c	Wed Mar 16 17:42:42 2011 +0200
+++ b/src/dsync/test-dsync-proxy-server-cmd.c	Wed Mar 16 17:46:29 2011 +0200
@@ -92,6 +92,7 @@
 	box.uid_next = 4023233417;
 	box.message_count = 4525;
 	box.highest_modseq = 18080787909545915012ULL;
+	box.first_recent_uid = 353;
 	test_worker->box_iter.next_box = &box;
 
 	test_assert(run_more() == 0);
@@ -101,7 +102,8 @@
 			   "4275878552\t"
 			   "4023233417\t"
 			   "4525\t"
-			   "18080787909545915012\n") == 0);
+			   "18080787909545915012\t"
+			   "353\n") == 0);
 	out_clear();
 
 	/* last mailbox */
@@ -231,7 +233,7 @@
 
 	test_assert(run_cmd("BOX-CREATE", "selectable", "?",
 			    "61", "2", TEST_MAILBOX_GUID2, "1234567890", "9876",
-			    "4610", "28427847284728", NULL) == 1);
+			    "4610", "28427847284728", "853", 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);
@@ -242,6 +244,7 @@
 	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.first_recent_uid == 853);
 	test_assert(event.box.last_change == 61);
 
 	test_end();
@@ -299,7 +302,7 @@
 
 	test_assert(run_cmd("BOX-UPDATE", "updated", "/",
 			    "53", "2", TEST_MAILBOX_GUID1, "34343", "22",
-			    "58293", "2238427847284728", NULL) == 1);
+			    "58293", "2238427847284728", "2482", 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);
@@ -310,6 +313,7 @@
 	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.first_recent_uid == 2482);
 	test_assert(event.box.last_change == 53);
 
 	test_end();


More information about the dovecot-cvs mailing list