dovecot-2.2: lib-index: Added mail_index_sync_no_warning() to pr...

dovecot at dovecot.org dovecot at dovecot.org
Thu Oct 9 15:27:53 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/193c82411d73
changeset: 17928:193c82411d73
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 09 18:27:14 2014 +0300
description:
lib-index: Added mail_index_sync_no_warning() to prevent "long transaction lock" warnings.
Use it with Maildir to prevent double-warning.

diffstat:

 src/lib-index/mail-index-sync.c                    |  9 ++++++++-
 src/lib-index/mail-index.h                         |  4 ++++
 src/lib-storage/index/maildir/maildir-sync-index.c |  1 +
 3 files changed, 13 insertions(+), 1 deletions(-)

diffs (58 lines):

diff -r fce66ec2ac1c -r 193c82411d73 src/lib-index/mail-index-sync.c
--- a/src/lib-index/mail-index-sync.c	Thu Oct 09 18:26:05 2014 +0300
+++ b/src/lib-index/mail-index-sync.c	Thu Oct 09 18:27:14 2014 +0300
@@ -24,6 +24,8 @@
 	ARRAY(struct mail_index_sync_list) sync_list;
 	uint32_t next_uid;
 	uint32_t last_tail_seq, last_tail_offset;
+
+	unsigned int no_warning:1;
 };
 
 static void mail_index_sync_add_expunge(struct mail_index_sync_ctx *ctx)
@@ -716,6 +718,11 @@
 		sync_list->idx = 0;
 }
 
+void mail_index_sync_no_warning(struct mail_index_sync_ctx *ctx)
+{
+	ctx->no_warning = TRUE;
+}
+
 static void mail_index_sync_end(struct mail_index_sync_ctx **_ctx)
 {
         struct mail_index_sync_ctx *ctx = *_ctx;
@@ -726,7 +733,7 @@
 
 	ctx->index->syncing = FALSE;
 	mail_transaction_log_sync_unlock(ctx->index->log,
-		"Mailbox was synchronized");
+		ctx->no_warning ? NULL : "Mailbox was synchronized");
 
 	mail_index_view_close(&ctx->view);
 	mail_index_transaction_rollback(&ctx->sync_trans);
diff -r fce66ec2ac1c -r 193c82411d73 src/lib-index/mail-index.h
--- a/src/lib-index/mail-index.h	Thu Oct 09 18:26:05 2014 +0300
+++ b/src/lib-index/mail-index.h	Thu Oct 09 18:27:14 2014 +0300
@@ -377,6 +377,10 @@
 /* Update result when refreshing index at the end of sync. */
 void mail_index_sync_set_commit_result(struct mail_index_sync_ctx *ctx,
 				       struct mail_index_transaction_commit_result *result);
+/* Don't log a warning even if syncing took over
+   MAIL_TRANSACTION_LOG_LOCK_WARN_SECS seconds. Usually this is called because
+   the caller itself already logged a warning about it. */
+void mail_index_sync_no_warning(struct mail_index_sync_ctx *ctx);
 /* Commit synchronization by writing all changes to mail index file. */
 int mail_index_sync_commit(struct mail_index_sync_ctx **ctx);
 /* Rollback synchronization - none of the changes listed by sync_next() are
diff -r fce66ec2ac1c -r 193c82411d73 src/lib-storage/index/maildir/maildir-sync-index.c
--- a/src/lib-storage/index/maildir/maildir-sync-index.c	Thu Oct 09 18:26:05 2014 +0300
+++ b/src/lib-storage/index/maildir/maildir-sync-index.c	Thu Oct 09 18:27:14 2014 +0300
@@ -316,6 +316,7 @@
 			  mailbox_get_path(&ctx->mbox->box), time_diff,
 			  ctx->new_msgs_count, ctx->flag_change_count,
 			  ctx->expunge_count);
+		mail_index_sync_no_warning(ctx->sync_ctx);
 	}
 
 	if (ret < 0)


More information about the dovecot-cvs mailing list