Mercurial > dovecot > core-2.2
changeset 2336:d4577ee85f0f HEAD
header caching fixes
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 18 Jul 2004 20:34:32 +0300 |
parents | 891990251008 |
children | beefcc4249ef |
files | src/lib-storage/index/index-mail-headers.c src/lib-storage/index/index-mail.c src/lib-storage/index/index-mail.h |
diffstat | 3 files changed, 25 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-mail-headers.c Sun Jul 18 15:54:42 2004 +0300 +++ b/src/lib-storage/index/index-mail-headers.c Sun Jul 18 20:34:32 2004 +0300 @@ -101,6 +101,14 @@ 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 @@ (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 @@ 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 @@ 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 @@ 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,
--- a/src/lib-storage/index/index-mail.c Sun Jul 18 15:54:42 2004 +0300 +++ b/src/lib-storage/index/index-mail.c Sun Jul 18 20:34:32 2004 +0300 @@ -175,7 +175,7 @@ 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 @@ 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 @@ /* 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; }
--- a/src/lib-storage/index/index-mail.h Sun Jul 18 15:54:42 2004 +0300 +++ b/src/lib-storage/index/index-mail.h Sun Jul 18 20:34:32 2004 +0300 @@ -114,7 +114,8 @@ 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);