From: Timo Sirainen Date: Tue, 30 Aug 2011 01:31:00 +0000 (+0300) Subject: lib-index: Added mail_cache_view_update_cache_decisions() X-Git-Tag: 2.1.alpha1~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8fa86f7ef06aa6cf0239c7ca2eb98889691d40d4;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Added mail_cache_view_update_cache_decisions() --- diff --git a/src/lib-index/mail-cache-decisions.c b/src/lib-index/mail-cache-decisions.c index 5273fc12b3..9f454d9162 100644 --- a/src/lib-index/mail-cache-decisions.c +++ b/src/lib-index/mail-cache-decisions.c @@ -79,6 +79,9 @@ void mail_cache_decision_state_update(struct mail_cache_view *view, i_assert(field < cache->fields_count); + if (view->no_decision_updates) + return; + mail_index_lookup_uid(view->view, seq, &uid); hdr = mail_index_get_header(view->view); @@ -124,7 +127,7 @@ void mail_cache_decision_add(struct mail_cache_view *view, uint32_t seq, i_assert(field < cache->fields_count); - if (MAIL_CACHE_IS_UNUSABLE(cache)) + if (MAIL_CACHE_IS_UNUSABLE(cache) || view->no_decision_updates) return; if (cache->fields[field].field.decision != MAIL_CACHE_DECISION_NO) { diff --git a/src/lib-index/mail-cache-private.h b/src/lib-index/mail-cache-private.h index 4ea905079b..97c60d77d2 100644 --- a/src/lib-index/mail-cache-private.h +++ b/src/lib-index/mail-cache-private.h @@ -198,6 +198,8 @@ struct mail_cache_view { buffer_t *cached_exists_buf; uint8_t cached_exists_value; uint32_t cached_exists_seq; + + unsigned int no_decision_updates:1; }; struct mail_cache_iterate_field { diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index 5964d9b634..bca893bddb 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -714,6 +714,12 @@ void mail_cache_view_close(struct mail_cache_view *view) i_free(view); } +void mail_cache_view_update_cache_decisions(struct mail_cache_view *view, + bool update) +{ + view->no_decision_updates = !update; +} + uint32_t mail_cache_get_first_new_seq(struct mail_index_view *view) { const struct mail_index_header *idx_hdr; diff --git a/src/lib-index/mail-cache.h b/src/lib-index/mail-cache.h index da48db7da3..e9c3f7d9e0 100644 --- a/src/lib-index/mail-cache.h +++ b/src/lib-index/mail-cache.h @@ -71,6 +71,11 @@ struct mail_cache_view * mail_cache_view_open(struct mail_cache *cache, struct mail_index_view *iview); void mail_cache_view_close(struct mail_cache_view *view); +/* Normally cache decisions are updated on lookup/add. Use this function to + enable/disable this (useful for precaching data). */ +void mail_cache_view_update_cache_decisions(struct mail_cache_view *view, + bool update); + /* Get index transaction specific cache transaction. */ struct mail_cache_transaction_ctx * mail_cache_get_transaction(struct mail_cache_view *view,