[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c, 1.64, 1.65 index-mail.c, 1.104, 1.105 index-mail.h, 1.42, 1.43

cras at dovecot.org cras at dovecot.org
Mon Jul 31 02:02:21 EEST 2006


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

Modified Files:
	index-mail-headers.c index-mail.c index-mail.h 
Log Message:
index_mail_cache_add() was used with lib-storage's internal indexes for most
of the received date, physical size and virtual size cache additions. This
may have caused all kinds of trouble, but since it went unnoticed this long
perhaps not..



Index: index-mail-headers.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- index-mail-headers.c	24 Jul 2006 00:26:47 -0000	1.64
+++ index-mail-headers.c	30 Jul 2006 23:02:16 -0000	1.65
@@ -72,7 +72,8 @@
 						    mail->data.seq,
 						    match_idx) == 0) {
 				/* this header doesn't exist. remember that. */
-				index_mail_cache_add(mail, match_idx, NULL, 0);
+				index_mail_cache_add_idx(mail, match_idx,
+							 NULL, 0);
 			}
 			match_idx++;
 		}
@@ -121,7 +122,8 @@
 		}
 
 		data = buffer_get_data(buf, &data_size);
-		index_mail_cache_add(mail, lines[i].field_idx, data, data_size);
+		index_mail_cache_add_idx(mail, lines[i].field_idx,
+					 data, data_size);
 	}
 
 	for (; match_idx < match_count; match_idx++) {
@@ -129,7 +131,7 @@
 		    mail_cache_field_exists(mail->trans->cache_view,
 					    mail->data.seq, match_idx) == 0) {
 			/* this header doesn't exist. remember that. */
-			index_mail_cache_add(mail, match_idx, NULL, 0);
+			index_mail_cache_add_idx(mail, match_idx, NULL, 0);
 		}
 	}
 
@@ -149,7 +151,7 @@
 		/* 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(mail, cache_field, NULL, 0);
+			index_mail_cache_add_idx(mail, cache_field, NULL, 0);
 	}
 	t_pop();
 }

Index: index-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- index-mail.c	24 Jul 2006 00:26:47 -0000	1.104
+++ index-mail.c	30 Jul 2006 23:02:16 -0000	1.105
@@ -235,7 +235,6 @@
 {
 	struct index_mail *mail = (struct index_mail *) _mail;
 	struct index_mail_data *data = &mail->data;
-	struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
 	const char *str;
 	int tz;
 
@@ -260,8 +259,7 @@
 			tz = 0;
 		}
 		data->sent_date.timezone = tz;
-		index_mail_cache_add(mail,
-				     cache_fields[MAIL_CACHE_SENT_DATE].idx,
+		index_mail_cache_add(mail, MAIL_CACHE_SENT_DATE,
 				     &data->sent_date, sizeof(data->sent_date));
 	}
 
@@ -295,7 +293,6 @@
 {
 	struct index_mail *mail = (struct index_mail *) _mail;
 	struct index_mail_data *data = &mail->data;
-	struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
 	struct message_size hdr_size, body_size;
 	uoff_t old_offset;
 
@@ -315,8 +312,7 @@
 	}
 
 	i_assert(data->virtual_size != (uoff_t)-1);
-	index_mail_cache_add(mail,
-			     cache_fields[MAIL_CACHE_VIRTUAL_FULL_SIZE].idx,
+	index_mail_cache_add(mail, MAIL_CACHE_VIRTUAL_FULL_SIZE,
 			     &data->virtual_size, sizeof(data->virtual_size));
 	return data->virtual_size;
 }
@@ -339,9 +335,16 @@
 	return (uoff_t)-1;
 }
 
-void index_mail_cache_add(struct index_mail *mail, unsigned int field,
+void index_mail_cache_add(struct index_mail *mail, enum index_cache_field field,
 			  const void *data, size_t data_size)
 {
+	index_mail_cache_add_idx(mail, mail->ibox->cache_fields[field].idx,
+				 data, data_size);
+}
+
+void index_mail_cache_add_idx(struct index_mail *mail, unsigned int field_idx,
+			      const void *data, size_t data_size)
+{
 	const struct mail_index_header *hdr;
 
 	/* First check if we've configured caching not to be used with
@@ -351,7 +354,7 @@
 		return;
 
 	mail_cache_add(mail->trans->cache_trans, mail->data.seq,
-		       field, data, data_size);
+		       field_idx, data, data_size);
 }
 
 static void parse_bodystructure_part_header(struct message_part *part,
@@ -398,11 +401,8 @@
 		cache_flags |= MAIL_CACHE_FLAG_BINARY_BODY;
 
 	if (cache_flags != data->cache_flags) {
-		unsigned int cache_field =
-			mail->ibox->cache_fields[MAIL_CACHE_FLAGS].idx;
-
 		data->cache_flags = cache_flags;
-		index_mail_cache_add(mail, cache_field,
+		index_mail_cache_add(mail, MAIL_CACHE_FLAGS,
 				     &cache_flags, sizeof(cache_flags));
 	}
 }
@@ -439,7 +439,8 @@
 	t_push();
 	buffer = buffer_create_dynamic(pool_datastack_create(), 1024);
 	message_part_serialize(mail->data.parts, buffer);
-	index_mail_cache_add(mail, cache_field, buffer->data, buffer->used);
+	index_mail_cache_add(mail, MAIL_CACHE_MESSAGE_PARTS,
+			     buffer->data, buffer->used);
 	t_pop();
 
 	data->messageparts_saved_to_cache = TRUE;
@@ -492,7 +493,8 @@
 		data->bodystructure = str_c(str);
 
 		if (cache_bodystructure) {
-			index_mail_cache_add(mail, cache_field_bodystructure,
+			index_mail_cache_add(mail,
+					     MAIL_CACHE_IMAP_BODYSTRUCTURE,
 					     str_c(str), str_len(str)+1);
 			bodystructure_cached = TRUE;
 		}
@@ -526,7 +528,7 @@
 		data->body = str_c(str);
 
 		if (cache_body) {
-			index_mail_cache_add(mail, cache_field_body,
+			index_mail_cache_add(mail, MAIL_CACHE_IMAP_BODY,
 					     str_c(str), str_len(str)+1);
 		}
 	}
@@ -540,7 +542,7 @@
 
 	if (mail_cache_field_want_add(mail->trans->cache_trans,
 				      mail->data.seq, cache_field)) {
-		index_mail_cache_add(mail, cache_field,
+		index_mail_cache_add(mail, MAIL_CACHE_VIRTUAL_FULL_SIZE,
 				     &mail->data.virtual_size,
 				     sizeof(mail->data.virtual_size));
 	}
@@ -911,7 +913,9 @@
 	data->seq = seq;
 	data->virtual_size = (uoff_t)-1;
 	data->physical_size = (uoff_t)-1;
-	data->received_date = data->sent_date.time = (time_t)-1;
+	data->save_date = (time_t)-1;
+	data->received_date = (time_t)-1;
+	data->sent_date.time = (time_t)-1;
 
 	if (!index_mail_get_fixed_field(mail, MAIL_CACHE_FLAGS,
 					&data->cache_flags,

Index: index-mail.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- index-mail.h	29 Jun 2006 11:08:55 -0000	1.42
+++ index-mail.h	30 Jul 2006 23:02:16 -0000	1.43
@@ -174,8 +174,10 @@
 				    enum index_cache_field field);
 uoff_t index_mail_get_cached_virtual_size(struct index_mail *mail);
 
-void index_mail_cache_add(struct index_mail *mail, unsigned int field,
+void index_mail_cache_add(struct index_mail *mail, enum index_cache_field field,
 			  const void *data, size_t data_size);
+void index_mail_cache_add_idx(struct index_mail *mail, unsigned int field_idx,
+			      const void *data, size_t data_size);
 
 void index_mail_cache_parse_init(struct mail *mail, struct istream *input);
 void index_mail_cache_parse_continue(struct mail *mail);



More information about the dovecot-cvs mailing list