From: Timo Sirainen Date: Tue, 2 Feb 2021 12:59:02 +0000 (+0200) Subject: lib-index: Rename mail_transaction_log.dotlock_count to dotlock_refcount X-Git-Tag: 2.3.16~279 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=751e99be42d3754d06d7522d30d91dc3cbce739f;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Rename mail_transaction_log.dotlock_count to dotlock_refcount 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. --- diff --git a/src/lib-index/mail-transaction-log-file.c b/src/lib-index/mail-transaction-log-file.c index f478bccb34..840c39f236 100644 --- a/src/lib-index/mail-transaction-log-file.c +++ b/src/lib-index/mail-transaction-log-file.c @@ -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); diff --git a/src/lib-index/mail-transaction-log-private.h b/src/lib-index/mail-transaction-log-private.h index 4fa5892dd9..975c968a55 100644 --- a/src/lib-index/mail-transaction-log-private.h +++ b/src/lib-index/mail-transaction-log-private.h @@ -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;