[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c, 1.28, 1.29 index-mail.c, 1.44, 1.45 index-mail.h, 1.18, 1.19

cras at dovecot.org cras at dovecot.org
Sun Jul 18 20:34:35 EEST 2004


Update of /home/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv18114/lib-storage/index

Modified Files:
	index-mail-headers.c index-mail.c index-mail.h 
Log Message:
header caching fixes



Index: index-mail-headers.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- index-mail-headers.c	18 Jul 2004 02:28:01 -0000	1.28
+++ index-mail-headers.c	18 Jul 2004 17:34:32 -0000	1.29
@@ -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,

Index: index-mail.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- index-mail.c	18 Jul 2004 02:25:07 -0000	1.44
+++ index-mail.c	18 Jul 2004 17:34:32 -0000	1.45
@@ -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;
 	}
 

Index: index-mail.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-mail.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- index-mail.h	18 Jul 2004 02:25:07 -0000	1.18
+++ index-mail.h	18 Jul 2004 17:34:32 -0000	1.19
@@ -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);



More information about the dovecot-cvs mailing list