changeset 6831:ddf393049f28 HEAD

When we create the initial cache file or recreate a broken one, write the offsets to transaction log using a temporary transaction instead of a long-running one which may get aborted.
author Timo Sirainen <tss@iki.fi>
date Sun, 18 Nov 2007 10:16:48 +0200
parents 3a41003bb1ae
children ea4d3778c99b
files src/lib-index/mail-cache-transaction.c
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-cache-transaction.c	Sun Nov 18 09:59:52 2007 +0200
+++ b/src/lib-index/mail-cache-transaction.c	Sun Nov 18 10:16:48 2007 +0200
@@ -113,13 +113,30 @@
 mail_cache_transaction_compress(struct mail_cache_transaction_ctx *ctx)
 {
 	struct mail_cache *cache = ctx->cache;
+	struct mail_index_view *view;
+	struct mail_index_transaction *trans;
+	uint32_t log_file_seq;
+	uoff_t log_file_offset;
+	int ret;
 
 	ctx->tried_compression = TRUE;
 
 	cache->need_compress_file_seq =
 		MAIL_CACHE_IS_UNUSABLE(cache) ? 0 : cache->hdr->file_seq;
 
-	return mail_cache_compress(cache, ctx->trans);
+	view = mail_index_view_open(cache->index);
+	trans = mail_index_transaction_begin(view,
+					MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL);
+	if (mail_cache_compress(cache, trans) < 0) {
+		mail_index_transaction_rollback(&trans);
+		ret = -1;
+	} else {
+		ret = mail_index_transaction_commit(&trans, &log_file_seq,
+						    &log_file_offset);
+	}
+	mail_index_view_close(&view);
+	mail_cache_transaction_reset(ctx);
+	return ret;
 }
 
 static void