dovecot: When we create the initial cache file or recreate a bro...

dovecot at dovecot.org dovecot at dovecot.org
Sun Nov 18 10:16:51 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/ddf393049f28
changeset: 6831:ddf393049f28
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Nov 18 10:16:48 2007 +0200
description:
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.

diffstat:

1 file changed, 18 insertions(+), 1 deletion(-)
src/lib-index/mail-cache-transaction.c |   19 ++++++++++++++++++-

diffs (35 lines):

diff -r 3a41003bb1ae -r ddf393049f28 src/lib-index/mail-cache-transaction.c
--- 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 m
 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


More information about the dovecot-cvs mailing list