]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
header caching fixes
authorTimo Sirainen <tss@iki.fi>
Sun, 18 Jul 2004 17:34:32 +0000 (20:34 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 18 Jul 2004 17:34:32 +0000 (20:34 +0300)
--HG--
branch : HEAD

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

index b0710cd6b2fdedb29d5a37918f34e6aa303cffcb..a2b8cb9864187e24fff758a27a58fe41e0b86288 100644 (file)
@@ -101,6 +101,14 @@ static void index_mail_parse_header_finish(struct index_mail *mail)
                               lines[i].field_idx, data, data_size);
        }
 
+       for (; match_idx < match_size; match_idx++) {
+               if (match[match_idx] == mail->header_match_value) {
+                       /* this header doesn't exist. remember that. */
+                       mail_cache_add(mail->trans->cache_trans,
+                                      mail->data.seq, match_idx, NULL, 0);
+               }
+       }
+
        t_pop();
 }
 
@@ -285,7 +293,8 @@ index_mail_parse_header_cb(struct message_part *part,
        (void)index_mail_parse_header(part, hdr, mail);
 }
 
-int index_mail_parse_headers(struct index_mail *mail)
+int index_mail_parse_headers(struct index_mail *mail,
+                            struct mailbox_header_lookup_ctx *headers)
 {
        struct index_mail_data *data = &mail->data;
 
@@ -294,7 +303,7 @@ int index_mail_parse_headers(struct index_mail *mail)
                        return FALSE;
        }
 
-       index_mail_parse_header_init(mail, NULL);
+       index_mail_parse_header_init(mail, headers);
 
        if (data->parts == NULL && data->parser_ctx == NULL) {
                /* initialize bodystructure parsing in case we read the whole
@@ -370,6 +379,8 @@ get_header_field_idx(struct index_mailbox *ibox, const char *field)
 const char *index_mail_get_header(struct mail *_mail, const char *field)
 {
        struct index_mail *mail = (struct index_mail *)_mail;
+       const char *headers[2];
+       struct mailbox_header_lookup_ctx *headers_ctx;
        const unsigned char *data;
        unsigned int field_idx;
        string_t *dest;
@@ -382,7 +393,13 @@ const char *index_mail_get_header(struct mail *_mail, const char *field)
        if (mail_cache_lookup_headers(mail->trans->cache_view, dest,
                                      mail->data.seq, &field_idx, 1) <= 0) {
                /* not in cache / error */
-               if (index_mail_parse_headers(mail) < 0)
+               headers[0] = field; headers[1] = NULL;
+               headers_ctx = mailbox_header_lookup_init(&mail->ibox->box,
+                                                        headers);
+               ret = index_mail_parse_headers(mail, headers_ctx);
+               mailbox_header_lookup_deinit(headers_ctx);
+
+               if (ret < 0)
                        return NULL;
 
                ret = mail_cache_lookup_headers(mail->trans->cache_view, dest,
index a1ef8d5403f33543ee89ace255931ec277dafe0a..313406595f11aa5ab83e092f40c2f7f5d90f51bd 100644 (file)
@@ -175,7 +175,7 @@ const struct message_part *index_mail_get_parts(struct mail *_mail)
                return data->parts;
 
        if (data->parser_ctx == NULL) {
-               if (!index_mail_parse_headers(mail))
+               if (!index_mail_parse_headers(mail, NULL))
                        return NULL;
        }
        index_mail_parse_body(mail, TRUE);
@@ -376,7 +376,7 @@ struct istream *index_mail_init_stream(struct index_mail *_mail,
 
        if (hdr_size != NULL) {
                if (!data->hdr_size_set) {
-                       if (!index_mail_parse_headers(mail))
+                       if (!index_mail_parse_headers(mail, NULL))
                                return NULL;
                }
 
@@ -411,7 +411,7 @@ static void index_mail_parse_bodystructure(struct index_mail *mail,
                /* we haven't parsed the header yet */
                data->save_bodystructure_header = TRUE;
                data->save_bodystructure_body = TRUE;
-               if (!index_mail_parse_headers(mail))
+               if (!index_mail_parse_headers(mail, NULL))
                        return;
        }
 
index 9bb0544385da157042535369b6ec8b6116c69777..265f876769370843bef623813ec4d2afc63cb99a 100644 (file)
@@ -114,7 +114,8 @@ void index_mail_parse_header_init(struct index_mail *mail,
 int index_mail_parse_header(struct message_part *part,
                            struct message_header_line *hdr,
                            struct index_mail *mail);
-int index_mail_parse_headers(struct index_mail *mail);
+int index_mail_parse_headers(struct index_mail *mail,
+                            struct mailbox_header_lookup_ctx *headers);
 void index_mail_headers_get_envelope(struct index_mail *mail);
 
 const char *index_mail_get_header(struct mail *_mail, const char *field);