[dovecot-cvs] dovecot/src/lib-storage/index index-mail.c, 1.54, 1.55 index-mail.h, 1.23, 1.24 index-storage.c, 1.63, 1.64 index-storage.h, 1.76, 1.77

cras at dovecot.org cras at dovecot.org
Sat Sep 4 15:44:16 EEST 2004


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

Modified Files:
	index-mail.c index-mail.h index-storage.c index-storage.h 
Log Message:
Cache field indexes are cache file specific, not globals.



Index: index-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- index-mail.c	4 Sep 2004 11:29:06 -0000	1.54
+++ index-mail.c	4 Sep 2004 12:44:14 -0000	1.55
@@ -13,7 +13,7 @@
 #include "index-storage.h"
 #include "index-mail.h"
 
-struct mail_cache_field cache_fields[MAIL_CACHE_FIELD_COUNT] = {
+struct mail_cache_field global_cache_fields[MAIL_CACHE_FIELD_COUNT] = {
 	{ "flags", 0, MAIL_CACHE_FIELD_BITMASK, sizeof(uint32_t), 0 },
 	{ "date.sent", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
 	  sizeof(struct mail_sent_date), 0 },
@@ -34,6 +34,7 @@
 
 static struct message_part *get_cached_parts(struct index_mail *mail)
 {
+	struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
 	struct message_part *part;
 	buffer_t *part_buf;
 	const char *error;
@@ -80,7 +81,7 @@
 	str = str_new(mail->pool, 32);
 	if (mail_cache_lookup_field(mail->trans->cache_view, str,
 				    mail->data.seq,
-				    cache_fields[field].idx) <= 0) {
+				    mail->ibox->cache_fields[field].idx) <= 0) {
 		p_free(mail->pool, str);
 		return NULL;
 	}
@@ -99,7 +100,7 @@
 	buf = buffer_create_data(pool_datastack_create(), data, data_size);
 	if (mail_cache_lookup_field(mail->trans->cache_view, buf,
 				    mail->data.seq,
-				    cache_fields[field].idx) <= 0) {
+				    mail->ibox->cache_fields[field].idx) <= 0) {
 		ret = FALSE;
 	} else {
 		i_assert(buffer_get_used_size(buf) == data_size);
@@ -115,7 +116,8 @@
 {
 	uoff_t uoff;
 
-	if (!index_mail_get_fixed_field(mail, cache_fields[field].idx,
+	if (!index_mail_get_fixed_field(mail,
+					mail->ibox->cache_fields[field].idx,
 					&uoff, sizeof(uoff)))
 		uoff = (uoff_t)-1;
 
@@ -209,6 +211,7 @@
 {
 	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;
 
@@ -272,6 +275,7 @@
 {
 	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;
 
 	if (data->virtual_size != (uoff_t)-1)
@@ -323,6 +327,7 @@
 static void index_mail_parse_body(struct index_mail *mail, int need_parts)
 {
 	struct index_mail_data *data = &mail->data;
+	struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
 	enum mail_cache_decision_type decision;
 	buffer_t *buffer;
 	const void *buf_data;
@@ -444,6 +449,7 @@
 					   enum index_cache_field field)
 {
 	struct index_mail_data *data = &mail->data;
+	struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
 	enum mail_cache_decision_type dec;
 	string_t *str;
 	int bodystructure_cached = FALSE;
@@ -515,6 +521,7 @@
 {
 	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;
 	string_t *str;
 
 	switch (field) {

Index: index-mail.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- index-mail.h	4 Sep 2004 10:27:30 -0000	1.23
+++ index-mail.h	4 Sep 2004 12:44:14 -0000	1.24
@@ -22,7 +22,7 @@
 
 	MAIL_CACHE_FIELD_COUNT
 };
-extern struct mail_cache_field cache_fields[MAIL_CACHE_FIELD_COUNT];
+extern struct mail_cache_field global_cache_fields[MAIL_CACHE_FIELD_COUNT];
 
 enum mail_cache_record_flag {
 	/* If binary flags are set, it's not checked whether mail is

Index: index-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- index-storage.c	4 Sep 2004 10:27:30 -0000	1.63
+++ index-storage.c	4 Sep 2004 12:44:14 -0000	1.64
@@ -186,8 +186,9 @@
 
 	for (arr = t_strsplit_spaces(fields, " ,"); *arr != NULL; arr++) {
 		for (i = 0; i < MAIL_CACHE_FIELD_COUNT; i++) {
-			if (strcasecmp(cache_fields[i].name, *arr) == 0) {
-				cache_fields[i].decision = dec;
+			if (strcasecmp(global_cache_fields[i].name,
+				       *arr) == 0) {
+				global_cache_fields[i].decision = dec;
 				break;
 			}
 		}
@@ -198,24 +199,33 @@
 	}
 }
 
-static void index_cache_register_defaults(struct mail_cache *cache)
+static void index_cache_register_defaults(struct index_mailbox *ibox)
 {
+	static int initialized = FALSE;
+	struct mail_cache *cache = ibox->cache;
 	const char *cache_env, *never_env;
 
-	cache_env = getenv("MAIL_CACHE_FIELDS");
-	if (cache_env == NULL)
-		cache_env = DEFAULT_CACHE_FIELDS;
-	never_env = getenv("MAIL_NEVER_CACHE_FIELDS");
-	if (never_env == NULL)
-		never_env = DEFAULT_NEVER_CACHE_FIELDS;
+	if (!initialized) {
+		initialized = TRUE;
 
-	set_cache_decisions("mail_cache_fields", cache_env,
-			    MAIL_CACHE_DECISION_TEMP);
-	set_cache_decisions("mail_never_cache_fields", never_env,
-			    MAIL_CACHE_DECISION_NO |
-			    MAIL_CACHE_DECISION_FORCED);
+		cache_env = getenv("MAIL_CACHE_FIELDS");
+		if (cache_env == NULL)
+			cache_env = DEFAULT_CACHE_FIELDS;
+		never_env = getenv("MAIL_NEVER_CACHE_FIELDS");
+		if (never_env == NULL)
+			never_env = DEFAULT_NEVER_CACHE_FIELDS;
 
-	mail_cache_register_fields(cache, cache_fields,
+		set_cache_decisions("mail_cache_fields", cache_env,
+				    MAIL_CACHE_DECISION_TEMP);
+		set_cache_decisions("mail_never_cache_fields", never_env,
+				    MAIL_CACHE_DECISION_NO |
+				    MAIL_CACHE_DECISION_FORCED);
+	}
+
+	ibox->cache_fields = i_malloc(sizeof(global_cache_fields));
+	memcpy(ibox->cache_fields, global_cache_fields,
+	       sizeof(global_cache_fields));
+	mail_cache_register_fields(cache, ibox->cache_fields,
 				   MAIL_CACHE_FIELD_COUNT);
 }
 
@@ -309,7 +319,7 @@
 			break;
 
 		ibox->cache = mail_index_get_cache(index);
-		index_cache_register_defaults(ibox->cache);
+		index_cache_register_defaults(ibox);
 		ibox->view = mail_index_view_open(index);
 		return ibox;
 	} while (0);
@@ -329,6 +339,7 @@
 	index_mailbox_check_remove_all(ibox);
 	if (ibox->index != NULL)
 		index_storage_unref(ibox->index);
+        i_free(ibox->cache_fields);
 	i_free(ibox->path);
 	i_free(ibox->control_dir);
 

Index: index-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- index-storage.h	28 Aug 2004 16:39:54 -0000	1.76
+++ index-storage.h	4 Sep 2004 12:44:14 -0000	1.77
@@ -64,6 +64,7 @@
 	uint32_t commit_log_file_seq;
 	uoff_t commit_log_file_offset;
 
+	struct mail_cache_field *cache_fields;
 	buffer_t *recent_flags;
 	uint32_t recent_flags_start_seq, recent_flags_count;
 	uint32_t synced_recent_count;



More information about the dovecot-cvs mailing list