dovecot: Added mail_index_ext_set_reset_id().

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 12 03:21:47 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/19bc2a4b3669
changeset: 5946:19bc2a4b3669
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 12 02:32:44 2007 +0300
description:
Added mail_index_ext_set_reset_id().

diffstat:

4 files changed, 34 insertions(+), 11 deletions(-)
src/lib-index/mail-index-transaction-private.h |    1 +
src/lib-index/mail-index-transaction.c         |   16 +++++++++++++---
src/lib-index/mail-index.h                     |    5 +++++
src/lib-index/mail-transaction-log-append.c    |   23 +++++++++++++++--------

diffs (123 lines):

diff -r ab487f1de905 -r 19bc2a4b3669 src/lib-index/mail-index-transaction-private.h
--- a/src/lib-index/mail-index-transaction-private.h	Thu Jul 12 02:23:59 2007 +0300
+++ b/src/lib-index/mail-index-transaction-private.h	Thu Jul 12 02:32:44 2007 +0300
@@ -51,6 +51,7 @@ struct mail_index_transaction {
 	ARRAY_DEFINE(ext_rec_updates, ARRAY_TYPE(seq_array));
 	ARRAY_DEFINE(ext_resizes, struct mail_transaction_ext_intro);
 	ARRAY_DEFINE(ext_resets, uint32_t);
+	ARRAY_DEFINE(ext_reset_ids, uint32_t);
 
 	ARRAY_DEFINE(keyword_updates,
 		     struct mail_index_transaction_keyword_update);
diff -r ab487f1de905 -r 19bc2a4b3669 src/lib-index/mail-index-transaction.c
--- a/src/lib-index/mail-index-transaction.c	Thu Jul 12 02:23:59 2007 +0300
+++ b/src/lib-index/mail-index-transaction.c	Thu Jul 12 02:32:44 2007 +0300
@@ -849,6 +849,16 @@ void mail_index_ext_reset(struct mail_in
 
 	t->log_updates = TRUE;
 
+	mail_index_ext_set_reset_id(t, ext_id, reset_id);
+
+	if (!array_is_created(&t->ext_resets))
+		i_array_init(&t->ext_resets, ext_id + 2);
+	array_idx_set(&t->ext_resets, ext_id, &reset_id);
+}
+
+void mail_index_ext_set_reset_id(struct mail_index_transaction *t,
+				 uint32_t ext_id, uint32_t reset_id)
+{
 	if (array_is_created(&t->ext_rec_updates) &&
 	    ext_id < array_count(&t->ext_rec_updates)) {
 		/* if extension records have been updated, clear them */
@@ -859,9 +869,9 @@ void mail_index_ext_reset(struct mail_in
 			array_clear(array);
 	}
 
-	if (!array_is_created(&t->ext_resets))
-		i_array_init(&t->ext_resets, ext_id + 2);
-	array_idx_set(&t->ext_resets, ext_id, &reset_id);
+	if (!array_is_created(&t->ext_reset_ids))
+		i_array_init(&t->ext_reset_ids, ext_id + 2);
+	array_idx_set(&t->ext_reset_ids, ext_id, &reset_id);
 }
 
 void mail_index_update_header_ext(struct mail_index_transaction *t,
diff -r ab487f1de905 -r 19bc2a4b3669 src/lib-index/mail-index.h
--- a/src/lib-index/mail-index.h	Thu Jul 12 02:23:59 2007 +0300
+++ b/src/lib-index/mail-index.h	Thu Jul 12 02:32:44 2007 +0300
@@ -391,6 +391,11 @@ void mail_index_ext_resize(struct mail_i
    used to figure this out, so it must be different every time. */
 void mail_index_ext_reset(struct mail_index_transaction *t, uint32_t ext_id,
 			  uint32_t reset_id);
+/* Discard existing extension updates and write new updates using the given
+   reset_id. The difference to mail_index_ext_reset() is that this doesn't
+   clear any existing record or header data. */
+void mail_index_ext_set_reset_id(struct mail_index_transaction *t,
+				 uint32_t ext_id, uint32_t reset_id);
 
 /* Returns extension header. */
 int mail_index_get_header_ext(struct mail_index_view *view, uint32_t ext_id,
diff -r ab487f1de905 -r 19bc2a4b3669 src/lib-index/mail-transaction-log-append.c
--- a/src/lib-index/mail-transaction-log-append.c	Thu Jul 12 02:23:59 2007 +0300
+++ b/src/lib-index/mail-transaction-log-append.c	Thu Jul 12 02:32:44 2007 +0300
@@ -251,10 +251,10 @@ mail_transaction_log_append_ext_intros(s
         const struct mail_transaction_ext_intro *resize;
 	struct mail_index_transaction_ext_hdr_update *const *hdrs;
 	struct mail_transaction_ext_reset ext_reset;
-	unsigned int update_count, resize_count, reset_count, ext_count = 0;
-	unsigned int hdrs_count;
+	unsigned int update_count, resize_count, ext_count = 0;
+	unsigned int hdrs_count, reset_id_count, reset_count;
 	uint32_t ext_id;
-	const uint32_t *reset;
+	const uint32_t *reset_ids, *reset;
 	const ARRAY_TYPE(seq_array) *update;
 	buffer_t *buf;
 
@@ -275,6 +275,13 @@ mail_transaction_log_append_ext_intros(s
 			ext_count = resize_count;
 	}
 
+	if (!array_is_created(&t->ext_reset_ids)) {
+		reset_ids = NULL;
+		reset_id_count = 0;
+	} else {
+		reset_ids = array_get(&t->ext_reset_ids, &reset_count);
+	}
+
 	if (!array_is_created(&t->ext_resets)) {
 		reset = NULL;
 		reset_count = 0;
@@ -301,15 +308,15 @@ mail_transaction_log_append_ext_intros(s
 
 	for (ext_id = 0; ext_id < ext_count; ext_id++) {
 		ext_reset.new_reset_id =
-			ext_id < reset_count && reset[ext_id] != 0 ?
-			reset[ext_id] : 0;
+			ext_id < reset_id_count && reset_ids[ext_id] != 0 ?
+			reset_ids[ext_id] : 0;
 		if ((ext_id < resize_count && resize[ext_id].name_size) ||
 		    (ext_id < update_count &&
 		     array_is_created(&update[ext_id])) ||
 		    ext_reset.new_reset_id != 0 ||
 		    (ext_id < hdrs_count && hdrs[ext_id] != NULL))
 			log_append_ext_intro(ctx, ext_id, 0);
-		if (ext_reset.new_reset_id != 0) {
+		if (ext_id < reset_count && reset[ext_id] != 0) {
 			log_append_buffer(ctx, buf, NULL,
 					  MAIL_TRANSACTION_EXT_RESET);
 		}
@@ -333,11 +340,11 @@ static void log_append_ext_rec_updates(s
 		updates = array_get_modifiable(&t->ext_rec_updates, &count);
 	}
 
-	if (!array_is_created(&t->ext_resets)) {
+	if (!array_is_created(&t->ext_reset_ids)) {
 		reset = NULL;
 		reset_count = 0;
 	} else {
-		reset = array_get_modifiable(&t->ext_resets, &reset_count);
+		reset = array_get_modifiable(&t->ext_reset_ids, &reset_count);
 	}
 
 	for (ext_id = 0; ext_id < count; ext_id++) {


More information about the dovecot-cvs mailing list