dovecot: We didn't cache correctly headers that existed in cache...

dovecot at dovecot.org dovecot at dovecot.org
Sun Jul 15 02:45:32 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/9da1ec15340d
changeset: 6006:9da1ec15340d
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jul 15 02:45:25 2007 +0300
description:
We didn't cache correctly headers that existed in cache file for other
messages, but we weren't currently interested of.

diffstat:

2 files changed, 14 insertions(+), 30 deletions(-)
src/lib-storage/index/index-mail-headers.c |   41 +++++++++-------------------
src/lib-storage/index/index-mail.h         |    3 --

diffs (79 lines):

diff -r 7c1e6ea4bfab -r 9da1ec15340d src/lib-storage/index/index-mail-headers.c
--- a/src/lib-storage/index/index-mail-headers.c	Sun Jul 15 02:43:34 2007 +0300
+++ b/src/lib-storage/index/index-mail-headers.c	Sun Jul 15 02:45:25 2007 +0300
@@ -140,25 +140,6 @@ static void index_mail_parse_header_fini
 			index_mail_cache_add_idx(mail, match_idx, NULL, 0);
 		}
 	}
-
-	/* set all non-found headers registered in cache */
-	for (i = 0; i < mail->data.all_cache_fields_count; i++) {
-		unsigned int cache_field = mail->data.all_cache_fields[i].idx;
-
-		/* first check that it isn't already added in this session */
-		if (cache_field < match_count &&
-		    (match[cache_field] & ~1) == mail->header_match_value)
-			continue;
-
-		if (strncasecmp(mail->data.all_cache_fields[i].name,
-				"hdr.", 4) != 0)
-			continue;
-
-		/* check that it hadn't been added in some older session */
-		if (mail_cache_field_exists(mail->trans->cache_view,
-					    mail->data.seq, cache_field) == 0)
-			index_mail_cache_add_idx(mail, cache_field, NULL, 0);
-	}
 	t_pop();
 }
 
@@ -188,7 +169,8 @@ void index_mail_parse_header_init(struct
 {
 	struct index_header_lookup_ctx *headers =
 		(struct index_header_lookup_ctx *)_headers;
-	size_t i;
+	const struct mail_cache_field *all_cache_fields;
+	unsigned int i, count;
 
 	mail->header_seq = mail->data.seq;
 	if (mail->header_data == NULL) {
@@ -232,14 +214,19 @@ void index_mail_parse_header_init(struct
 			      &mail->header_match_value);
 	}
 
-	/* get a list of all currently cached fields. we'll later set those
-	   headers that weren't found to empty. if this list is get later,
-	   it's possible that it has already changed (cache has no permanent
-	   write locks, remember!) and we set some headers to empty even
-	   though they really exist. */
-	mail->data.all_cache_fields =
+	/* register also all the other headers that exist in cache file */
+	t_push();
+	all_cache_fields =
 		mail_cache_register_get_list(mail->ibox->cache,
-			mail->data_pool, &mail->data.all_cache_fields_count);
+					     pool_datastack_create(), &count);
+	for (i = 0; i < count; i++) {
+		if (strncasecmp(all_cache_fields[i].name, "hdr.", 4) == 0) {
+			array_idx_set(&mail->header_match,
+				      all_cache_fields[i].idx,
+				      &mail->header_match_value);
+		}
+	}
+	t_pop();
 }
 
 static void index_mail_parse_finish_imap_envelope(struct index_mail *mail)
diff -r 7c1e6ea4bfab -r 9da1ec15340d src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h	Sun Jul 15 02:43:34 2007 +0300
+++ b/src/lib-storage/index/index-mail.h	Sun Jul 15 02:45:25 2007 +0300
@@ -90,9 +90,6 @@ struct index_mail_data {
 	struct message_parser_ctx *parser_ctx;
 	int parsing_count;
 	ARRAY_TYPE(keywords) keywords;
-
-	const struct mail_cache_field *all_cache_fields;
-	unsigned int all_cache_fields_count;
 
 	unsigned int save_sent_date:1;
 	unsigned int save_envelope:1;


More information about the dovecot-cvs mailing list