]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Added mail_cache_view_update_cache_decisions()
authorTimo Sirainen <tss@iki.fi>
Tue, 30 Aug 2011 01:31:00 +0000 (04:31 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 30 Aug 2011 01:31:00 +0000 (04:31 +0300)
src/lib-index/mail-cache-decisions.c
src/lib-index/mail-cache-private.h
src/lib-index/mail-cache.c
src/lib-index/mail-cache.h

index 5273fc12b3a52b51a127c0af6a9e58dc92f3731d..9f454d9162cb2dadd9c9d890e7faf32e2910c073 100644 (file)
@@ -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) {
index 4ea905079b1f74cebe0d0dc3a32005bada23392e..97c60d77d2c38a0ba6e0480247a2fc5fab752e75 100644 (file)
@@ -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 {
index 5964d9b6347ed63ddb606c0010a0d7408026339c..bca893bddb5e0d9412e88eec69d5fdea90ec82de 100644 (file)
@@ -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;
index da48db7da34a2b50137694de05517336d278b79a..e9c3f7d9e0a68441c1554ba4959088286355c1c2 100644 (file)
@@ -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,