]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Keep a linked list of mail_cache_views
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 1 Apr 2020 19:08:42 +0000 (22:08 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 09:41:42 +0000 (12:41 +0300)
Assert-crash on cache deinit if any views are still open.

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

index ad5fd8e5949e9cca42d0dfb91e894945e9d24375..0483cfcd716f93d5629cc31956fb28065f9773f6 100644 (file)
@@ -109,6 +109,8 @@ struct mail_cache {
        /* mail_cache_map() increases this always. */
        unsigned int remap_counter;
 
+       struct mail_cache_view *views;
+
        struct dotlock_settings dotlock_settings;
        struct file_lock *file_lock;
 
@@ -161,6 +163,7 @@ struct mail_cache_missing_reason_cache {
 
 struct mail_cache_view {
        struct mail_cache *cache;
+       struct mail_cache_view *prev, *next;
        struct mail_index_view *view, *trans_view;
 
        struct mail_cache_transaction_ctx *transaction;
index 4c3e4f73c02cc06dbf176b1e39dfc3b18006751e..de81bcbebaf8124222cf267ede149af4de711afe 100644 (file)
@@ -4,6 +4,7 @@
 #include "array.h"
 #include "buffer.h"
 #include "hash.h"
+#include "llist.h"
 #include "nfs-workarounds.h"
 #include "file-cache.h"
 #include "mmap-util.h"
@@ -591,6 +592,9 @@ void mail_cache_free(struct mail_cache **_cache)
        struct mail_cache *cache = *_cache;
 
        *_cache = NULL;
+
+       i_assert(cache->views == NULL);
+
        if (cache->file_cache != NULL)
                file_cache_free(&cache->file_cache);
 
@@ -854,6 +858,7 @@ mail_cache_view_open(struct mail_cache *cache, struct mail_index_view *iview)
        view->cached_exists_buf =
                buffer_create_dynamic(default_pool,
                                      cache->file_fields_count + 10);
+       DLLIST_PREPEND(&cache->views, view);
        return view;
 }
 
@@ -868,6 +873,7 @@ void mail_cache_view_close(struct mail_cache_view **_view)
            !view->cache->compressing)
                 (void)mail_cache_header_fields_update(view->cache);
 
+       DLLIST_REMOVE(&view->cache->views, view);
        buffer_free(&view->cached_exists_buf);
        i_free(view);
 }