]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Replace mail_cache_flush_and_unlock() with mail_cache_unlock() where it...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 30 Mar 2020 14:39:46 +0000 (17:39 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 09:41:43 +0000 (12:41 +0300)
In various error handling code paths it's not useful to try to flush any
headers. It might just make things worse.

src/lib-index/mail-cache-compress.c
src/lib-index/mail-cache-fields.c
src/lib-index/mail-cache-transaction.c
src/lib-index/mail-cache.c

index 3f0a9d6ccb0a2efa48713b8a6945eed0298eb4b7..127059251e31aa657779a2f375b306d05148d774 100644 (file)
@@ -366,7 +366,7 @@ mail_cache_compress_write(struct mail_cache *cache,
        array_free(&ext_offsets);
 
        if (*unlock) {
-               (void)mail_cache_flush_and_unlock(cache);
+               mail_cache_unlock(cache);
                *unlock = FALSE;
        }
 
@@ -435,7 +435,7 @@ static int mail_cache_compress_locked(struct mail_cache *cache,
                cache->need_compress_file_seq = 0;
 
                if (*unlock) {
-                       (void)mail_cache_flush_and_unlock(cache);
+                       (void)mail_cache_unlock(cache);
                        *unlock = FALSE;
                }
 
@@ -510,10 +510,9 @@ mail_cache_compress_full(struct mail_cache *cache,
        cache->compressing = TRUE;
        ret = mail_cache_compress_locked(cache, compress_file_seq, trans, &unlock);
        cache->compressing = FALSE;
-       if (unlock) {
-               if (mail_cache_flush_and_unlock(cache) < 0)
-                       ret = -1;
-       }
+       if (unlock)
+               mail_cache_unlock(cache);
+       i_assert(!cache->hdr_modified);
        if (ret < 0) {
                /* the fields may have been updated in memory already.
                   reverse those changes by re-reading them from file. */
index dc2e753d862c5060fa00d05f1cb6c035e649a072..1d1f4b2d0e4e74738ba64fdb7b7e6f73196f5cbc 100644 (file)
@@ -563,8 +563,8 @@ int mail_cache_header_fields_update(struct mail_cache *cache)
        T_BEGIN {
                ret = mail_cache_header_fields_update_locked(cache);
        } T_END;
-       if (mail_cache_flush_and_unlock(cache) < 0)
-               ret = -1;
+       i_assert(!cache->hdr_modified);
+       mail_cache_unlock(cache);
        return ret;
 }
 
index 4734fb3fd90f5b8eb9d67211236b69e23a9c6bc2..7e1457fd6abd57c458893b469082416cd1ae2b44 100644 (file)
@@ -220,7 +220,7 @@ static int mail_cache_transaction_lock(struct mail_cache_transaction_ctx *ctx)
                   it to free up some space. */
                if (cache->hdr->continued_record_count > 0 ||
                    cache->hdr->deleted_record_count > 0) {
-                       (void)mail_cache_flush_and_unlock(cache);
+                       mail_cache_unlock(cache);
                        (void)mail_cache_transaction_compress(ctx);
                        return mail_cache_transaction_lock(ctx);
                }
@@ -469,7 +469,7 @@ mail_cache_transaction_flush(struct mail_cache_transaction_ctx *ctx)
        i_assert(ctx->last_rec_pos <= ctx->cache_data->used);
 
        if (mail_cache_transaction_update_fields(ctx) < 0) {
-               (void)mail_cache_flush_and_unlock(ctx->cache);
+               mail_cache_unlock(ctx->cache);
                return -1;
        }
 
index f69b0ae958ff92a3f97cd7f745b53eb0d8d62660..0aa9c0e1d83b19a3f2a0c04c1dd5991263190819 100644 (file)
@@ -823,7 +823,7 @@ mail_cache_lock_full(struct mail_cache *cache, bool nonblock)
        if (cache->read_buf != NULL)
                buffer_set_used_size(cache->read_buf, 0);
        if ((ret = mail_cache_map_all(cache)) <= 0) {
-               (void)mail_cache_flush_and_unlock(cache);
+               mail_cache_unlock(cache);
                return ret;
        }
        cache->hdr_copy = *cache->hdr;