[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c, 1.59.2.2, 1.59.2.3 index-mail.c, 1.93.2.3, 1.93.2.4 index-mail.h, 1.37, 1.37.2.1

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


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

Modified Files:
      Tag: branch_1_0
	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.59.2.2
retrieving revision 1.59.2.3
diff -u -d -r1.59.2.2 -r1.59.2.3
--- index-mail-headers.c	24 Jul 2006 00:26:45 -0000	1.59.2.2
+++ index-mail-headers.c	30 Jul 2006 23:02:15 -0000	1.59.2.3
@@ -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.93.2.3
retrieving revision 1.93.2.4
diff -u -d -r1.93.2.3 -r1.93.2.4
--- index-mail.c	24 Jul 2006 00:26:45 -0000	1.93.2.3
+++ index-mail.c	30 Jul 2006 23:02:15 -0000	1.93.2.4
@@ -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,
@@ -433,7 +436,7 @@
 
 	if (cache_flags != data->cache_flags) {
 		data->cache_flags = cache_flags;
-		index_mail_cache_add(mail, cache_fields[MAIL_CACHE_FLAGS].idx,
+		index_mail_cache_add(mail, MAIL_CACHE_FLAGS,
 				     &cache_flags, sizeof(cache_flags));
 	}
 
@@ -452,8 +455,7 @@
 		message_part_serialize(mail->data.parts, buffer);
 
 		buf_data = buffer_get_data(buffer, &buf_size);
-                index_mail_cache_add(mail,
-				     cache_fields[MAIL_CACHE_MESSAGEPART].idx,
+                index_mail_cache_add(mail, MAIL_CACHE_MESSAGEPART,
 				     buf_data, buf_size);
 		t_pop();
 		data->messageparts_saved_to_cache = TRUE;
@@ -573,7 +575,7 @@
 		    dec != (MAIL_CACHE_DECISION_NO |
 			    MAIL_CACHE_DECISION_FORCED)) {
 			index_mail_cache_add(mail,
-				cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx,
+				MAIL_CACHE_IMAP_BODYSTRUCTURE,
 				str_c(str), str_len(str)+1);
 			bodystructure_cached = TRUE;
 		}
@@ -592,9 +594,8 @@
 		if (!bodystructure_cached && !plain_bodystructure &&
 		    dec != (MAIL_CACHE_DECISION_NO |
 			    MAIL_CACHE_DECISION_FORCED)) {
-			index_mail_cache_add(mail,
-				       cache_fields[MAIL_CACHE_IMAP_BODY].idx,
-				       str_c(str), str_len(str)+1);
+			index_mail_cache_add(mail, MAIL_CACHE_IMAP_BODY,
+					     str_c(str), str_len(str)+1);
 		}
 	}
 }
@@ -792,7 +793,8 @@
 	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->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.37
retrieving revision 1.37.2.1
diff -u -d -r1.37 -r1.37.2.1
--- index-mail.h	18 Jan 2006 22:16:43 -0000	1.37
+++ index-mail.h	30 Jul 2006 23:02:15 -0000	1.37.2.1
@@ -172,7 +172,9 @@
 uoff_t index_mail_get_cached_virtual_size(struct index_mail *mail);
 time_t index_mail_get_cached_received_date(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);
 
 #endif



More information about the dovecot-cvs mailing list