From: Timo Sirainen Date: Thu, 26 Mar 2020 13:31:48 +0000 (+0200) Subject: lib-index: Remove mail_cache_field_private.adding field X-Git-Tag: 2.3.11.2~441 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5be9b6379e6aa36e101990cb65b44a4095d3da09;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Remove mail_cache_field_private.adding field This was used to make sure that cache compression didn't drop a field that was just being added. After previous commit the cache is locked before this code is even reached, so it's no longer possible. --- diff --git a/src/lib-index/mail-cache-compress.c b/src/lib-index/mail-cache-compress.c index 7f2071079c..c81ca14cff 100644 --- a/src/lib-index/mail-cache-compress.c +++ b/src/lib-index/mail-cache-compress.c @@ -226,15 +226,14 @@ mail_cache_copy(struct mail_cache *cache, struct mail_index_transaction *trans, /* if the decision isn't forced and this field hasn't been accessed for a while, drop it */ if ((dec & MAIL_CACHE_DECISION_FORCED) == 0 && - priv->field.last_used < max_drop_time && - !priv->adding) { + priv->field.last_used < max_drop_time) { dec = MAIL_CACHE_DECISION_NO; priv->field.decision = dec; } /* drop all fields we don't want */ if ((dec & ~MAIL_CACHE_DECISION_FORCED) == - MAIL_CACHE_DECISION_NO && !priv->adding) { + MAIL_CACHE_DECISION_NO) { priv->used = FALSE; priv->field.last_used = 0; } diff --git a/src/lib-index/mail-cache-private.h b/src/lib-index/mail-cache-private.h index b757490d84..0fe2c748f1 100644 --- a/src/lib-index/mail-cache-private.h +++ b/src/lib-index/mail-cache-private.h @@ -80,7 +80,6 @@ struct mail_cache_field_private { /* Unused fields aren't written to cache file */ bool used:1; - bool adding:1; bool decision_dirty:1; }; diff --git a/src/lib-index/mail-cache-transaction.c b/src/lib-index/mail-cache-transaction.c index cfcab3aad7..508ee48240 100644 --- a/src/lib-index/mail-cache-transaction.c +++ b/src/lib-index/mail-cache-transaction.c @@ -635,18 +635,15 @@ mail_cache_header_fields_write(struct mail_cache *cache, const buffer_t *buffer) return 0; } -static void mail_cache_mark_adding(struct mail_cache *cache, bool set) +static void mail_cache_mark_used(struct mail_cache *cache) { unsigned int i; /* we want to avoid adding all the fields one by one to the cache file, so just add all of them at once in here. the unused ones get dropped later when compressing. */ - for (i = 0; i < cache->fields_count; i++) { - if (set) - cache->fields[i].used = TRUE; - cache->fields[i].adding = set; - } + for (i = 0; i < cache->fields_count; i++) + cache->fields[i].used = TRUE; } static int @@ -736,9 +733,8 @@ mail_cache_trans_get_file_field(struct mail_cache_transaction_ctx *ctx, file_field = ctx->cache->field_file_map[field_idx]; if (MAIL_CACHE_IS_UNUSABLE(ctx->cache) || file_field == (uint32_t)-1) { /* we'll have to add this field to headers */ - mail_cache_mark_adding(ctx->cache, TRUE); + mail_cache_mark_used(ctx->cache); ret = mail_cache_header_add_field(ctx, field_idx); - mail_cache_mark_adding(ctx->cache, FALSE); if (ret < 0) return -1;