[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c, 1.52, 1.53 index-mail.h, 1.35, 1.36

cras at dovecot.org cras at dovecot.org
Wed Jul 13 11:25:26 EEST 2005


Update of /var/lib/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv30127/lib-storage/index

Modified Files:
	index-mail-headers.c index-mail.h 
Log Message:
Header caching was more or less broken.



Index: index-mail-headers.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- index-mail-headers.c	4 Jul 2005 11:32:22 -0000	1.52
+++ index-mail-headers.c	13 Jul 2005 08:25:24 -0000	1.53
@@ -37,13 +37,11 @@
 static void index_mail_parse_header_finish(struct index_mail *mail)
 {
 	struct index_mail_line *lines;
-	const struct mail_cache_field *all_cache_fields;
 	const unsigned char *header, *data;
 	const uint8_t *match;
 	buffer_t *buf;
 	size_t data_size;
 	unsigned int i, j, count, match_idx, match_count;
-	unsigned int all_cache_fields_count;
 	int noncontiguous;
 
 	t_push();
@@ -139,23 +137,24 @@
 	}
 
 	/* set all non-found headers registered in cache */
-	all_cache_fields =
-		mail_cache_register_get_list(mail->ibox->cache,
-					     pool_datastack_create(),
-					     &all_cache_fields_count);
-	for (i = 0; i < all_cache_fields_count; i++) {
-		unsigned int cache_field = all_cache_fields[i].idx;
+	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 */
-		if (all_cache_fields[i].idx < match_count &&
-		    match[cache_field] == mail->header_match_value)
+		/* 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(all_cache_fields[i].name, "hdr.", 4) != 0)
+		if (strncasecmp(mail->data.all_cache_fields[i].name,
+				"hdr.", 4) != 0)
 			continue;
 
-		mail_cache_add(mail->trans->cache_trans,
-			       mail->data.seq, cache_field, NULL, 0);
+		/* 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) {
+			mail_cache_add(mail->trans->cache_trans,
+				       mail->data.seq, cache_field, NULL, 0);
+		}
 	}
 	t_pop();
 }
@@ -225,6 +224,15 @@
 			      get_header_field_idx(mail->ibox, "Date"),
 			      &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 =
+		mail_cache_register_get_list(mail->ibox->cache,
+			mail->data_pool, &mail->data.all_cache_fields_count);
 }
 
 static void index_mail_parse_finish_imap_envelope(struct index_mail *mail)

Index: index-mail.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- index-mail.h	3 Jul 2005 15:15:47 -0000	1.35
+++ index-mail.h	13 Jul 2005 08:25:24 -0000	1.36
@@ -89,6 +89,9 @@
 	int parsing_count;
 	array_t ARRAY_DEFINE(keywords, const char *);
 
+	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;
 	unsigned int save_bodystructure_header:1;



More information about the dovecot-cvs mailing list