dovecot-2.0: lib-index: Added mail_index_update_highest_modseq().

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 6 03:30:50 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/1411f157ffdd
changeset: 9725:1411f157ffdd
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 05 20:01:34 2009 -0400
description:
lib-index: Added mail_index_update_highest_modseq().

diffstat:

6 files changed, 29 insertions(+), 3 deletions(-)
src/lib-index/mail-index-sync-update.c             |    7 +++++--
src/lib-index/mail-index-transaction-finish.c      |    4 ++++
src/lib-index/mail-index-transaction-private.h     |    1 +
src/lib-index/mail-index-transaction-update.c      |   15 ++++++++++++++-
src/lib-index/mail-index.h                         |    3 +++
src/lib-index/test-mail-index-transaction-finish.c |    2 ++

diffs (111 lines):

diff -r 773b91d3ed13 -r 1411f157ffdd src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c	Wed Aug 05 20:01:02 2009 -0400
+++ b/src/lib-index/mail-index-sync-update.c	Wed Aug 05 20:01:34 2009 -0400
@@ -325,14 +325,17 @@ sync_modseq_update(struct mail_index_syn
 
 	end = CONST_PTR_OFFSET(u, size);
 	for (; u < end; u++) {
-		if (!mail_index_lookup_seq(view, u->uid, &seq))
+		if (u->uid == 0)
+			seq = 0;
+		else if (!mail_index_lookup_seq(view, u->uid, &seq))
 			continue;
 
 		min_modseq = ((uint64_t)u->modseq_high32 >> 32) |
 			u->modseq_low32;
 		if (highest_modseq < min_modseq)
 			highest_modseq = min_modseq;
-		if (mail_index_modseq_set(view, seq, min_modseq) < 0) {
+		if (seq != 0 &&
+		    mail_index_modseq_set(view, seq, min_modseq) < 0) {
 			mail_index_sync_set_corrupted(ctx,
 				"modseqs updated before they were enabled");
 			return -1;
diff -r 773b91d3ed13 -r 1411f157ffdd src/lib-index/mail-index-transaction-finish.c
--- a/src/lib-index/mail-index-transaction-finish.c	Wed Aug 05 20:01:02 2009 -0400
+++ b/src/lib-index/mail-index-transaction-finish.c	Wed Aug 05 20:01:34 2009 -0400
@@ -342,5 +342,9 @@ int mail_index_transaction_finish(struct
 	/* finally convert all sequences to UIDs before we write them,
 	   but after we've checked and removed conflicts */
 	mail_index_transaction_convert_to_uids(t);
+
+	/* and kind of ugly way to update highest modseq */
+	if (t->min_highest_modseq != 0)
+		mail_index_update_modseq(t, 0, t->min_highest_modseq);
 	return 0;
 }
diff -r 773b91d3ed13 -r 1411f157ffdd src/lib-index/mail-index-transaction-private.h
--- a/src/lib-index/mail-index-transaction-private.h	Wed Aug 05 20:01:02 2009 -0400
+++ b/src/lib-index/mail-index-transaction-private.h	Wed Aug 05 20:01:34 2009 -0400
@@ -68,6 +68,7 @@ struct mail_index_transaction {
 		     struct mail_index_transaction_keyword_update);
 	ARRAY_TYPE(seq_range) keyword_resets;
 
+	uint64_t min_highest_modseq;
 	uint64_t max_modseq;
 	ARRAY_TYPE(seq_range) *conflict_seqs;
 
diff -r 773b91d3ed13 -r 1411f157ffdd src/lib-index/mail-index-transaction-update.c
--- a/src/lib-index/mail-index-transaction-update.c	Wed Aug 05 20:01:02 2009 -0400
+++ b/src/lib-index/mail-index-transaction-update.c	Wed Aug 05 20:01:34 2009 -0400
@@ -91,6 +91,7 @@ void mail_index_transaction_reset_v(stru
 	t->last_update_idx = 0;
 	t->min_flagupdate_seq = 0;
 	t->max_flagupdate_seq = 0;
+	t->min_highest_modseq = 0;
 
 	memset(t->pre_hdr_mask, 0, sizeof(t->pre_hdr_mask));
 	memset(t->post_hdr_mask, 0, sizeof(t->post_hdr_mask));
@@ -114,7 +115,8 @@ void mail_index_transaction_set_log_upda
 		array_is_created(&t->expunges) ||
 		array_is_created(&t->keyword_resets) ||
 		array_is_created(&t->keyword_updates) ||
-		t->pre_hdr_changed || t->post_hdr_changed;
+		t->pre_hdr_changed || t->post_hdr_changed ||
+		t->min_highest_modseq != 0;
 }
 
 void mail_index_update_day_headers(struct mail_index_transaction *t)
@@ -268,6 +270,17 @@ void mail_index_update_modseq(struct mai
 	u->uid = seq;
 	u->modseq_low32 = min_modseq & 0xffffffff;
 	u->modseq_high32 = min_modseq >> 32;
+
+	t->log_updates = TRUE;
+}
+
+void mail_index_update_highest_modseq(struct mail_index_transaction *t,
+				      uint64_t min_modseq)
+{
+	if (t->min_highest_modseq < min_modseq)
+		t->min_highest_modseq = min_modseq;
+
+	t->log_updates = TRUE;
 }
 
 static void
diff -r 773b91d3ed13 -r 1411f157ffdd src/lib-index/mail-index.h
--- a/src/lib-index/mail-index.h	Wed Aug 05 20:01:02 2009 -0400
+++ b/src/lib-index/mail-index.h	Wed Aug 05 20:01:34 2009 -0400
@@ -426,6 +426,9 @@ void mail_index_update_flags_range(struc
 /* Update message's modseq to be at least min_modseq. */
 void mail_index_update_modseq(struct mail_index_transaction *t, uint32_t seq,
 			      uint64_t min_modseq);
+/* Update highest modseq to be at least min_modseq. */
+void mail_index_update_highest_modseq(struct mail_index_transaction *t,
+				      uint64_t min_modseq);
 /* Reset the index before committing this transaction. This is usually done
    only when UIDVALIDITY changes. */
 void mail_index_reset(struct mail_index_transaction *t);
diff -r 773b91d3ed13 -r 1411f157ffdd src/lib-index/test-mail-index-transaction-finish.c
--- a/src/lib-index/test-mail-index-transaction-finish.c	Wed Aug 05 20:01:02 2009 -0400
+++ b/src/lib-index/test-mail-index-transaction-finish.c	Wed Aug 05 20:01:34 2009 -0400
@@ -27,6 +27,8 @@ void mail_index_transaction_sort_appends
 void mail_index_transaction_sort_appends(struct mail_index_transaction *t ATTR_UNUSED) {}
 int mail_index_map(struct mail_index *index ATTR_UNUSED,
 		   enum mail_index_sync_handler_type type ATTR_UNUSED) { return 1; }
+void mail_index_update_modseq(struct mail_index_transaction *t ATTR_UNUSED, uint32_t seq ATTR_UNUSED,
+			      uint64_t min_modseq ATTR_UNUSED) {}
 
 const struct mail_index_record *
 mail_index_lookup(struct mail_index_view *view ATTR_UNUSED, uint32_t seq)


More information about the dovecot-cvs mailing list