[dovecot-cvs] dovecot/src/lib-storage/index index-mail.h, 1.34, 1.35 index-mail-headers.c, 1.50, 1.51

cras at dovecot.org cras at dovecot.org
Sun Jul 3 18:15:50 EEST 2005


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

Modified Files:
	index-mail.h index-mail-headers.c 
Log Message:
Mark *all* non-found headers that are registered in cache file as non-found
at the end of header parsing.



Index: index-mail.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- index-mail.h	3 Jul 2005 14:18:28 -0000	1.34
+++ index-mail.h	3 Jul 2005 15:15:47 -0000	1.35
@@ -129,9 +129,9 @@
 
 void index_mail_parse_header_init(struct index_mail *mail,
 				  struct mailbox_header_lookup_ctx *headers);
-int index_mail_parse_header(struct message_part *part,
-			    struct message_header_line *hdr,
-			    struct index_mail *mail);
+void 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,
 			     struct mailbox_header_lookup_ctx *headers);
 void index_mail_headers_get_envelope(struct index_mail *mail);

Index: index-mail-headers.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- index-mail-headers.c	3 Jul 2005 13:07:50 -0000	1.50
+++ index-mail-headers.c	3 Jul 2005 15:15:47 -0000	1.51
@@ -36,11 +36,13 @@
 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();
@@ -135,6 +137,25 @@
 		}
 	}
 
+	/* 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;
+
+		/* first check that it isn't already added */
+		if (all_cache_fields[i].idx < match_count &&
+		    match[cache_field] == mail->header_match_value)
+			continue;
+
+		if (strncasecmp(all_cache_fields[i].name, "hdr.", 4) != 0)
+			continue;
+
+		mail_cache_add(mail->trans->cache_trans,
+			       mail->data.seq, cache_field, NULL, 0);
+	}
 	t_pop();
 }
 
@@ -217,9 +238,9 @@
 		       MAIL_CACHE_IMAP_ENVELOPE, str_data(str), str_len(str));
 }
 
-int index_mail_parse_header(struct message_part *part,
-			    struct message_header_line *hdr,
-			    struct index_mail *mail)
+void index_mail_parse_header(struct message_part *part,
+			     struct message_header_line *hdr,
+			     struct index_mail *mail)
 {
 	struct index_mail_data *data = &mail->data;
 	enum mail_cache_decision_type decision;
@@ -251,7 +272,7 @@
 		}
 		index_mail_parse_header_finish(mail);
                 data->save_bodystructure_header = FALSE;
-		return TRUE;
+		return;
 	}
 
 	if (!hdr->continued) {
@@ -266,7 +287,7 @@
 
 	if (field_idx == (unsigned int)-1) {
 		/* we don't want this field */
-		return TRUE;
+		return;
 	}
 
 	if (!hdr->continued) {
@@ -291,7 +312,7 @@
 		   (field_idx >= count ||
 		    (match[field_idx] & ~1) != mail->header_match_value)) {
 		/* we don't need to do anything with this header */
-		return TRUE;
+		return;
 	}
 
 	if (!hdr->continued) {
@@ -307,7 +328,6 @@
 		data->parse_line.end_pos = str_len(mail->header_data);
 		array_append(&mail->header_lines, &data->parse_line, 1);
 	}
-	return TRUE;
 }
 
 static void
@@ -316,7 +336,7 @@
 {
 	struct index_mail *mail = context;
 
-	(void)index_mail_parse_header(part, hdr, mail);
+	index_mail_parse_header(part, hdr, mail);
 }
 
 int index_mail_parse_headers(struct index_mail *mail,
@@ -562,7 +582,7 @@
 	if (hdr != NULL && hdr->eoh)
 		*matched = FALSE;
 
-	(void)index_mail_parse_header(NULL, hdr, mail);
+	index_mail_parse_header(NULL, hdr, mail);
 }
 
 struct istream *



More information about the dovecot-cvs mailing list