]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Replaced some automatic transaction log unlocks with asserts.
authorTimo Sirainen <tss@iki.fi>
Thu, 9 Oct 2014 15:23:41 +0000 (18:23 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 9 Oct 2014 15:23:41 +0000 (18:23 +0300)
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.

src/lib-index/mail-transaction-log-file.c
src/lib-index/mail-transaction-log.c

index 65d30ba5a0c75b4a357a4ae42c3aa43672c3cda6..e7294e16ab6da3f7090211ba221a8ae5a2cf685c 100644 (file)
@@ -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) {
index 851e2e7615ed15a09194de9f78cb8719cccde549..4e9488ae88abc108471c3a22d6253451f82ec790 100644 (file)
@@ -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;
 }