]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Rename mail_transaction_log.dotlock_count to dotlock_refcount
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 2 Feb 2021 12:59:02 +0000 (14:59 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 3 May 2021 13:01:05 +0000 (13:01 +0000)
Also change it to a signed integer and add asserts to make sure it's >=0.
This is how refcounts are handled generally in Dovecot.

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

index f478bccb344c52aec016c982efcc2efee393dd30..840c39f236655d545e3881ddc7d7593fe668fe70 100644 (file)
@@ -309,15 +309,16 @@ mail_transaction_log_file_dotlock(struct mail_transaction_log_file *file)
        struct dotlock_settings dotlock_set;
        int ret;
 
-       if (file->log->dotlock_count > 0)
+       if (file->log->dotlock_refcount > 0)
                ret = 1;
        else {
+               i_assert(file->log->dotlock_refcount == 0);
                mail_transaction_log_get_dotlock_set(file->log, &dotlock_set);
                ret = file_dotlock_create(&dotlock_set, file->filepath, 0,
                                          &file->log->dotlock);
        }
        if (ret > 0) {
-               file->log->dotlock_count++;
+               file->log->dotlock_refcount++;
                file->locked = TRUE;
                file->lock_created = time(NULL);
                return 0;
@@ -339,7 +340,8 @@ mail_transaction_log_file_undotlock(struct mail_transaction_log_file *file)
 {
        int ret;
 
-       if (--file->log->dotlock_count > 0)
+       i_assert(file->log->dotlock_refcount >= 0);
+       if (--file->log->dotlock_refcount > 0)
                return 0;
 
        ret = file_dotlock_delete(&file->log->dotlock);
index 4fa5892dd9f60af48be95ce8039bb874d576046f..975c968a55d627ab97ea31634054f46bca0040b0 100644 (file)
@@ -87,7 +87,7 @@ struct mail_transaction_log {
           if _open() failed, it's left there for _create(). */
        struct mail_transaction_log_file *open_file;
 
-       unsigned int dotlock_count;
+       int dotlock_refcount;
        struct dotlock *dotlock;
 
        bool nfs_flush:1;