From: Timo Sirainen Date: Wed, 1 Apr 2020 19:08:42 +0000 (+0300) Subject: lib-index: Keep a linked list of mail_cache_views X-Git-Tag: 2.3.11.2~428 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5131f57df8ab20284f825883932597ab7695a5f;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Keep a linked list of mail_cache_views Assert-crash on cache deinit if any views are still open. --- diff --git a/src/lib-index/mail-cache-private.h b/src/lib-index/mail-cache-private.h index ad5fd8e594..0483cfcd71 100644 --- a/src/lib-index/mail-cache-private.h +++ b/src/lib-index/mail-cache-private.h @@ -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; diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index 4c3e4f73c0..de81bcbeba 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -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); }