changeset 12251:ab2222fd3f5d

lib-index: Always update index map while committing a transaction. The previous code was doing this only in some situations, which was probably enough, except maybe in some special cases. The log file was also read until EOF always anyway, so the only thing this was saving was some CPU. With the new behavior the committing stage should be more reliable, and also makes it easier to do changes without accidentally breaking it.
author Timo Sirainen <tss@iki.fi>
date Wed, 06 Oct 2010 18:20:26 +0100
parents d0ddc30f0eef
children 74ede782269d
files src/lib-index/mail-index-transaction-finish.c src/lib-index/mail-index-transaction-private.h src/lib-index/mail-index-transaction.c
diffstat 3 files changed, 8 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction-finish.c	Wed Oct 06 18:18:30 2010 +0100
+++ b/src/lib-index/mail-index-transaction-finish.c	Wed Oct 06 18:20:26 2010 +0100
@@ -316,7 +316,7 @@
 	mail_index_convert_to_uid_ranges(t, &t->keyword_resets);
 }
 
-int mail_index_transaction_finish(struct mail_index_transaction *t)
+void mail_index_transaction_finish(struct mail_index_transaction *t)
 {
 	if (array_is_created(&t->appends)) {
 		mail_index_update_day_headers(t);
@@ -324,11 +324,6 @@
 	}
 	mail_index_transaction_finish_flag_updates(t);
 
-	if (array_is_created(&t->ext_reset_atomic) || t->max_modseq != 0) {
-		if (mail_index_map(t->view->index,
-				   MAIL_INDEX_SYNC_HANDLER_HEAD) <= 0)
-			return -1;
-	}
 	if (array_is_created(&t->ext_reset_atomic))
 		transaction_update_atomic_reset_ids(t);
 	if (t->max_modseq != 0)
@@ -340,5 +335,4 @@
 	/* 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;
 }
--- a/src/lib-index/mail-index-transaction-private.h	Wed Oct 06 18:18:30 2010 +0100
+++ b/src/lib-index/mail-index-transaction-private.h	Wed Oct 06 18:20:26 2010 +0100
@@ -126,7 +126,7 @@
 bool mail_index_cancel_keyword_updates(struct mail_index_transaction *t,
 				       uint32_t seq);
 
-int mail_index_transaction_finish(struct mail_index_transaction *t);
+void mail_index_transaction_finish(struct mail_index_transaction *t);
 void mail_index_transaction_export(struct mail_index_transaction *t,
 				   struct mail_transaction_log_append_ctx *append_ctx);
 int mail_transaction_expunge_guid_cmp(const struct mail_transaction_expunge_guid *e1,
--- a/src/lib-index/mail-index-transaction.c	Wed Oct 06 18:18:30 2010 +0100
+++ b/src/lib-index/mail-index-transaction.c	Wed Oct 06 18:20:26 2010 +0100
@@ -109,12 +109,10 @@
 	}
 	file = t->view->index->log->head;
 
-	if (!t->view->index->log_sync_locked) {
-		/* update sync_offset */
-		if (mail_transaction_log_file_map(file, file->sync_offset,
-						  (uoff_t)-1) <= 0)
-			return -1;
-	}
+	/* make sure we have everything mapped */
+	if (mail_index_map(t->view->index, MAIL_INDEX_SYNC_HANDLER_HEAD) <= 0)
+		return -1;
+
 	i_assert(file->sync_offset >= file->buffer_offset);
 	ctx->new_highest_modseq = file->sync_highest_modseq;
 	return 1;
@@ -135,9 +133,8 @@
 		return -1;
 	ret = mail_transaction_log_file_refresh(t, ctx);
 	if (ret > 0) {
-		ret = mail_index_transaction_finish(t);
-		if (ret == 0)
-			mail_index_transaction_export(t, ctx);
+		mail_index_transaction_finish(t);
+		mail_index_transaction_export(t, ctx);
 	}
 
 	mail_transaction_log_get_head(log, &log_seq1, &log_offset1);