From: Timo Sirainen Date: Fri, 20 Mar 2020 14:42:45 +0000 (+0200) Subject: lib-index: mail_cache_header_add_field_locked() - Move unlocking to caller X-Git-Tag: 2.3.11.2~449 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db040453511aa8d45342737af2748a401d45debe;p=thirdparty%2Fdovecot%2Fcore.git lib-index: mail_cache_header_add_field_locked() - Move unlocking to caller --- diff --git a/src/lib-index/mail-cache-transaction.c b/src/lib-index/mail-cache-transaction.c index 54980bc3e0..9a83a8ac35 100644 --- a/src/lib-index/mail-cache-transaction.c +++ b/src/lib-index/mail-cache-transaction.c @@ -651,15 +651,11 @@ mail_cache_header_add_field_locked(struct mail_cache *cache, int ret; /* re-read header to make sure we don't lose any fields. */ - if (mail_cache_header_fields_read(cache) < 0) { - (void)mail_cache_unlock(cache); + if (mail_cache_header_fields_read(cache) < 0) return -1; - } if (cache->field_file_map[field_idx] != (uint32_t)-1) { /* it was already added */ - if (mail_cache_unlock(cache) < 0) - return -1; return 0; } @@ -682,9 +678,6 @@ mail_cache_header_add_field_locked(struct mail_cache *cache, "lost unexpectedly", cache->filepath); ret = -1; } - - if (mail_cache_unlock(cache) < 0) - ret = -1; return ret; } @@ -692,6 +685,7 @@ static int mail_cache_header_add_field(struct mail_cache_transaction_ctx *ctx, unsigned int field_idx) { struct mail_cache *cache = ctx->cache; + int ret; if (MAIL_INDEX_IS_IN_MEMORY(cache->index)) { if (cache->file_fields_count <= field_idx) { @@ -721,7 +715,10 @@ static int mail_cache_header_add_field(struct mail_cache_transaction_ctx *ctx, if (mail_cache_transaction_lock(ctx) <= 0) return -1; } - return mail_cache_header_add_field_locked(cache, field_idx); + ret = mail_cache_header_add_field_locked(cache, field_idx); + if (mail_cache_unlock(cache) < 0) + ret = -1; + return ret; } static int