]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: change caching decision for lazy requests in cache lookup
authorMarkus Valentin <markus.valentin@open-xchange.com>
Tue, 3 Sep 2019 12:33:03 +0000 (14:33 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 10 Sep 2019 07:02:34 +0000 (10:02 +0300)
In case  lookup_abort is set to NOT_IN_CACHE_START_CACHING update the
cacheing decision for the requested field.

src/lib-storage/index/index-mail.c

index 7a5e992c395a4ce49574c94f44d4503d281822f7..416f3685f3d09363436c62e0a251564c5a9df69e 100644 (file)
@@ -77,12 +77,22 @@ static int index_mail_write_body_snippet(struct index_mail *mail);
 int index_mail_cache_lookup_field(struct index_mail *mail, buffer_t *buf,
                                  unsigned int field_idx)
 {
+       struct mail *_mail = &mail->mail.mail;
        int ret;
 
        ret = mail_cache_lookup_field(mail->mail.mail.transaction->cache_view,
                                      buf, mail->data.seq, field_idx);
        if (ret > 0)
                mail->mail.mail.transaction->stats.cache_hit_count++;
+
+       /* If the request was lazy mark the field as cache wanted. */
+       if (_mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE_START_CACHING &&
+           mail_cache_field_get_decision(_mail->box->cache, field_idx) ==
+           MAIL_CACHE_DECISION_NO) {
+               mail_cache_decision_add(_mail->transaction->cache_view,
+                                       _mail->seq, field_idx);
+       }
+
        return ret;
 }