From: Markus Valentin Date: Tue, 3 Sep 2019 12:30:15 +0000 (+0200) Subject: lib-storage: introduce MAIL_LOOKUP_ABORT_NOT_IN_CACHE_START_CACHING X-Git-Tag: 2.3.9~217 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=95ccad80a898b1461faf5a12ec3f6a906caa6879;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: introduce MAIL_LOOKUP_ABORT_NOT_IN_CACHE_START_CACHING In some cases we would like to mark an field as to be cached but still don't fetch it now. For this occasions this change introduces a new enum value for mail_lookup_abort which allows to implement such a behaviour. --- diff --git a/src/lib-storage/index/cydir/cydir-mail.c b/src/lib-storage/index/cydir/cydir-mail.c index 450d71defc..08132bb9e8 100644 --- a/src/lib-storage/index/cydir/cydir-mail.c +++ b/src/lib-storage/index/cydir/cydir-mail.c @@ -21,7 +21,7 @@ static int cydir_mail_stat(struct mail *mail, struct stat *st_r) { const char *path; - if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) { + if (mail->lookup_abort >= MAIL_LOOKUP_ABORT_NOT_IN_CACHE) { mail_set_aborted(mail); return -1; } diff --git a/src/lib-storage/index/index-mail-headers.c b/src/lib-storage/index/index-mail-headers.c index 2efa751957..ed3ba87c5b 100644 --- a/src/lib-storage/index/index-mail-headers.c +++ b/src/lib-storage/index/index-mail-headers.c @@ -652,7 +652,7 @@ index_mail_get_raw_headers(struct index_mail *mail, const char *field, /* don't try to parse headers recursively. we're here because message size was wrong and istream-mail wants to log some cached headers. */ - i_assert(mail->mail.mail.lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE); + i_assert(mail->mail.mail.lookup_abort >= MAIL_LOOKUP_ABORT_NOT_IN_CACHE); mail_set_aborted(&mail->mail.mail); return -1; } diff --git a/src/lib-storage/index/maildir/maildir-mail.c b/src/lib-storage/index/maildir/maildir-mail.c index 21688b89af..759c717d02 100644 --- a/src/lib-storage/index/maildir/maildir-mail.c +++ b/src/lib-storage/index/maildir/maildir-mail.c @@ -107,7 +107,7 @@ static int maildir_mail_stat(struct mail *mail, struct stat *st_r) const char *path; int fd, ret; - if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) { + if (mail->lookup_abort >= MAIL_LOOKUP_ABORT_NOT_IN_CACHE) { mail_set_aborted(mail); return -1; } diff --git a/src/lib-storage/index/raw/raw-mail.c b/src/lib-storage/index/raw/raw-mail.c index 54a0f254d2..64b33a91aa 100644 --- a/src/lib-storage/index/raw/raw-mail.c +++ b/src/lib-storage/index/raw/raw-mail.c @@ -14,7 +14,7 @@ static int raw_mail_stat(struct mail *mail) struct raw_mailbox *mbox = RAW_MAILBOX(mail->box); const struct stat *st; - if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) { + if (mail->lookup_abort >= MAIL_LOOKUP_ABORT_NOT_IN_CACHE) { mail_set_aborted(mail); return -1; } diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index 43aea8d4dd..d901b6778b 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -379,7 +379,12 @@ enum mail_lookup_abort { operations to be performed, such as stat()ing a file. */ MAIL_LOOKUP_ABORT_READ_MAIL, /* Abort if the operation can't be done fully using cache file */ - MAIL_LOOKUP_ABORT_NOT_IN_CACHE + MAIL_LOOKUP_ABORT_NOT_IN_CACHE, + /* Abort if the operation can't be done fully using cache file. + * During this lookup all cache lookups that have "no" decision + * will be changed to "tmp". This way the field will start to be + * cached in the future. */ + MAIL_LOOKUP_ABORT_NOT_IN_CACHE_START_CACHING, }; enum mail_access_type {