dovecot-2.2: lib-index: Replaced some automatic transaction log ...

dovecot at dovecot.org dovecot at dovecot.org
Thu Oct 9 15:24:23 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/623a9f46c747
changeset: 17926:623a9f46c747
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 09 18:23:41 2014 +0300
description:
lib-index: Replaced some automatic transaction log unlocks with asserts.
Some earlier Dovecot versions were read-locking transaction logs and this
was useful there. But now we only do exclusive locking for the log head, so
it's an error not to explicitly unlock the files.

diffstat:

 src/lib-index/mail-transaction-log-file.c |   2 +-
 src/lib-index/mail-transaction-log.c      |  10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diffs (41 lines):

diff -r ec1fd3dc0a74 -r 623a9f46c747 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c	Thu Oct 09 18:20:56 2014 +0300
+++ b/src/lib-index/mail-transaction-log-file.c	Thu Oct 09 18:23:41 2014 +0300
@@ -101,7 +101,7 @@
 
 	*_file = NULL;
 
-	mail_transaction_log_file_unlock(file);
+	i_assert(!file->locked);
 
 	for (p = &file->log->files; *p != NULL; p = &(*p)->next) {
 		if (*p == file) {
diff -r ec1fd3dc0a74 -r 623a9f46c747 src/lib-index/mail-transaction-log.c
--- a/src/lib-index/mail-transaction-log.c	Thu Oct 09 18:20:56 2014 +0300
+++ b/src/lib-index/mail-transaction-log.c	Thu Oct 09 18:23:41 2014 +0300
@@ -210,10 +210,9 @@
 
 		mail_transaction_log_file_free(&file);
 	}
-	/* if we still have locked files with refcount=0, unlock them */
+	/* sanity check: we shouldn't have locked refcount=0 files */
 	for (; file != NULL; file = file->next) {
-		if (file->locked && file->refcount == 0)
-			mail_transaction_log_file_unlock(file);
+		i_assert(!file->locked || file->refcount > 0);
 	}
 	i_assert(log->head == NULL || log->files != NULL);
 }
@@ -267,8 +266,11 @@
 
 	if (--log->head->refcount == 0)
 		mail_transaction_logs_clean(log);
-	else
+	else {
+		/* the newly created log file is already locked */
+		i_assert(file->locked);
 		mail_transaction_log_file_unlock(log->head);
+	}
 	mail_transaction_log_set_head(log, file);
 	return 0;
 }


More information about the dovecot-cvs mailing list