[dovecot-cvs] dovecot: Added mail_index_transction_reset().

dovecot at dovecot.org dovecot at dovecot.org
Tue May 22 18:31:42 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/7274df228c04
changeset: 5642:7274df228c04
user:      Timo Sirainen <tss at iki.fi>
date:      Tue May 22 18:31:35 2007 +0300
description:
Added mail_index_transction_reset().

diffstat:

2 files changed, 25 insertions(+), 1 deletion(-)
src/lib-index/mail-index-transaction.c |   24 +++++++++++++++++++++++-
src/lib-index/mail-index.h             |    2 ++

diffs (53 lines):

diff -r 209a71c37012 -r 7274df228c04 src/lib-index/mail-index-transaction.c
--- a/src/lib-index/mail-index-transaction.c	Tue May 22 15:43:51 2007 +0300
+++ b/src/lib-index/mail-index-transaction.c	Tue May 22 18:31:35 2007 +0300
@@ -18,7 +18,7 @@ void (*hook_mail_index_transaction_creat
 void (*hook_mail_index_transaction_created)
 		(struct mail_index_transaction *t) = NULL;
 
-static void mail_index_transaction_free(struct mail_index_transaction *t)
+void mail_index_transction_reset(struct mail_index_transaction *t)
 {
 	ARRAY_TYPE(seq_array) *recs;
 	unsigned i, count;
@@ -59,6 +59,28 @@ static void mail_index_transaction_free(
 		array_free(&t->ext_resizes);
 	if (array_is_created(&t->ext_resets))
 		array_free(&t->ext_resets);
+
+	t->first_new_seq = mail_index_view_get_messages_count(t->view)+1;
+	t->last_new_seq = 0;
+	t->last_update_idx = 0;
+
+	memset(t->pre_hdr_mask, 0, sizeof(t->pre_hdr_mask));
+	memset(t->post_hdr_mask, 0, sizeof(t->post_hdr_mask));
+
+	if (t->cache_trans_ctx != NULL) {
+		mail_cache_transaction_rollback(t->cache_trans_ctx);
+                t->cache_trans_ctx = NULL;
+	}
+
+	t->appends_nonsorted = FALSE;
+	t->pre_hdr_changed = FALSE;
+	t->post_hdr_changed = FALSE;
+	t->log_updates = FALSE;
+}
+
+static void mail_index_transaction_free(struct mail_index_transaction *t)
+{
+	mail_index_transction_reset(t);
 
 	array_free(&t->module_contexts);
 	mail_index_view_transaction_unref(t->view);
diff -r 209a71c37012 -r 7274df228c04 src/lib-index/mail-index.h
--- a/src/lib-index/mail-index.h	Tue May 22 15:43:51 2007 +0300
+++ b/src/lib-index/mail-index.h	Tue May 22 18:31:35 2007 +0300
@@ -187,6 +187,8 @@ int mail_index_transaction_commit(struct
 				  uint32_t *log_file_seq_r,
 				  uoff_t *log_file_offset_r);
 void mail_index_transaction_rollback(struct mail_index_transaction **t);
+/* Discard all changes in the transaction. */
+void mail_index_transction_reset(struct mail_index_transaction *t);
 
 /* Returns a view to transaction. Currently this differs from normal view only
    in that it contains newly appended messages in transaction. The view can


More information about the dovecot-cvs mailing list