From: Timo Sirainen Date: Thu, 9 Oct 2014 15:23:41 +0000 (+0300) Subject: lib-index: Replaced some automatic transaction log unlocks with asserts. X-Git-Tag: 2.2.14~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da4376093d4e1b26b14ea1e945689fb7056fe0a0;p=thirdparty%2Fdovecot%2Fcore.git 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. --- diff --git a/src/lib-index/mail-transaction-log-file.c b/src/lib-index/mail-transaction-log-file.c index 65d30ba5a0..e7294e16ab 100644 --- a/src/lib-index/mail-transaction-log-file.c +++ b/src/lib-index/mail-transaction-log-file.c @@ -101,7 +101,7 @@ void mail_transaction_log_file_free(struct mail_transaction_log_file **_file) *_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 --git a/src/lib-index/mail-transaction-log.c b/src/lib-index/mail-transaction-log.c index 851e2e7615..4e9488ae88 100644 --- a/src/lib-index/mail-transaction-log.c +++ b/src/lib-index/mail-transaction-log.c @@ -210,10 +210,9 @@ void mail_transaction_logs_clean(struct mail_transaction_log *log) 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 @@ int mail_transaction_log_rotate(struct mail_transaction_log *log, bool reset) 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; }