]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Remove mail_cache_field_private.adding field
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 26 Mar 2020 13:31:48 +0000 (15:31 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 08:57:20 +0000 (08:57 +0000)
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.

src/lib-index/mail-cache-compress.c
src/lib-index/mail-cache-private.h
src/lib-index/mail-cache-transaction.c

index 7f2071079c2cd3ea962fc53afba4759703c84e99..c81ca14cff6791de9a42c67fe7efe62f1a0b4268 100644 (file)
@@ -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;
                        }
index b757490d842031e09776ecc1d36482d80ae18c61..0fe2c748f19bf1bcb97b8adc565d3a5e7011c35a 100644 (file)
@@ -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;
 };
 
index cfcab3aad794366b26e92cc5301f4ca01a25b806..508ee48240ce85cca77765060ab073fe9c1c9daa 100644 (file)
@@ -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;