[dovecot-cvs] dovecot/src/lib-storage/index index-mail.c, 1.52, 1.53 index-mail.h, 1.22, 1.23 index-storage.c, 1.62, 1.63

cras at dovecot.org cras at dovecot.org
Sat Sep 4 13:27:32 EEST 2004


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

Modified Files:
	index-mail.c index-mail.h index-storage.c 
Log Message:
Fixed cache flags to work again. Flags are cached by default now.



Index: index-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- index-mail.c	28 Aug 2004 13:10:22 -0000	1.52
+++ index-mail.c	4 Sep 2004 10:27:30 -0000	1.53
@@ -14,7 +14,7 @@
 #include "index-mail.h"
 
 struct mail_cache_field cache_fields[MAIL_CACHE_FIELD_COUNT] = {
-	{ "index.flags", 0, MAIL_CACHE_FIELD_BITMASK, sizeof(uint32_t), 0 },
+	{ "flags", 0, MAIL_CACHE_FIELD_BITMASK, sizeof(uint32_t), 0 },
 	{ "date.sent", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
 	  sizeof(struct mail_sent_date), 0 },
 	{ "date.received", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
@@ -327,6 +327,7 @@
 	buffer_t *buffer;
 	const void *buf_data;
 	size_t buf_size;
+	uint32_t cache_flags;
 
 	i_assert(data->parts == NULL);
 	i_assert(data->parser_ctx != NULL);
@@ -351,6 +352,7 @@
 	data->body_size = data->parts->body_size;
 	data->body_size_set = TRUE;
 
+	cache_flags = 0;
 	if (!mail->mail.has_nuls && !mail->mail.has_no_nuls) {
 		/* we know the NULs now, update them */
 		if ((data->parts->flags & MESSAGE_PART_FLAG_HAS_NULS) != 0) {
@@ -361,18 +363,21 @@
 			mail->mail.has_no_nuls = TRUE;
 		}
 
-		/* update cache_flags */
-		/*FIXME:cache_flags =
-			mail_cache_get_record_flags(mail->trans->cache_view,
-						    mail->data.seq);
 		if (mail->mail.has_nuls)
-			cache_flags |= MAIL_INDEX_FLAG_HAS_NULS;
+			cache_flags |= MAIL_CACHE_FLAG_HAS_NULS;
 		else
-			cache_flags |= MAIL_INDEX_FLAG_HAS_NO_NULS;
+			cache_flags |= MAIL_CACHE_FLAG_HAS_NO_NULS;
+	}
 
-		(void)mail_cache_update_record_flags(mail->trans->cache_view,
-						     mail->data.seq,
-						     cache_flags);*/
+	if (data->hdr_size.virtual_size == data->hdr_size.physical_size)
+		cache_flags |= MAIL_CACHE_FLAG_BINARY_HEADER;
+	if (data->body_size.virtual_size == data->body_size.physical_size)
+		cache_flags |= MAIL_CACHE_FLAG_BINARY_BODY;
+
+	if ((cache_flags & ~data->cache_flags) != 0) {
+		mail_cache_add(mail->trans->cache_trans, mail->data.seq,
+			       cache_fields[MAIL_CACHE_FLAGS].idx,
+			       &cache_flags, sizeof(cache_flags));
 	}
 
 	/* see if we want to cache the message part */
@@ -634,20 +639,22 @@
 	memset(data, 0, sizeof(*data));
 	p_clear(mail->pool);
 
-	cache_flags = 0;//FIXME:mail_cache_get_record_flags(mail->trans->cache_view, seq);
-
-	mail->mail.seq = seq;
-	mail->mail.uid = rec->uid;
-	mail->mail.has_nuls = (cache_flags & MAIL_INDEX_FLAG_HAS_NULS) != 0;
-	mail->mail.has_no_nuls =
-		(cache_flags & MAIL_INDEX_FLAG_HAS_NO_NULS) != 0;
-
 	data->rec = rec;
 	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;
 
+	if (!index_mail_get_fixed_field(mail, MAIL_CACHE_FLAGS,
+					&cache_flags, sizeof(cache_flags)))
+		cache_flags = 0;
+
+	mail->mail.seq = seq;
+	mail->mail.uid = rec->uid;
+	mail->mail.has_nuls = (cache_flags & MAIL_CACHE_FLAG_HAS_NULS) != 0;
+	mail->mail.has_no_nuls =
+		(cache_flags & MAIL_CACHE_FLAG_HAS_NO_NULS) != 0;
+
 	t_push();
 
 	/* if some wanted fields are cached, get them */

Index: index-mail.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- index-mail.h	28 Aug 2004 10:32:17 -0000	1.22
+++ index-mail.h	4 Sep 2004 10:27:30 -0000	1.23
@@ -7,7 +7,7 @@
 
 enum index_cache_field {
 	/* fixed size fields */
-	MAIL_CACHE_INDEX_FLAGS = 0,
+	MAIL_CACHE_FLAGS = 0,
 	MAIL_CACHE_SENT_DATE,
 	MAIL_CACHE_RECEIVED_DATE,
 	MAIL_CACHE_VIRTUAL_FULL_SIZE,
@@ -29,13 +29,13 @@
 	   missing CRs. So this flag may be set as an optimization for
 	   regular non-binary mails as well if it's known that it contains
 	   valid CR+LF line breaks. */
-	MAIL_INDEX_FLAG_BINARY_HEADER		= 0x0001,
-	MAIL_INDEX_FLAG_BINARY_BODY		= 0x0002,
+	MAIL_CACHE_FLAG_BINARY_HEADER		= 0x0001,
+	MAIL_CACHE_FLAG_BINARY_BODY		= 0x0002,
 
 	/* Mail header or body is known to contain NUL characters. */
-	MAIL_INDEX_FLAG_HAS_NULS		= 0x0004,
+	MAIL_CACHE_FLAG_HAS_NULS		= 0x0004,
 	/* Mail header or body is known to not contain NUL characters. */
-	MAIL_INDEX_FLAG_HAS_NO_NULS		= 0x0008
+	MAIL_CACHE_FLAG_HAS_NO_NULS		= 0x0008
 };
 
 struct mail_sent_date {
@@ -67,6 +67,7 @@
 
 	uint32_t seq;
 	const struct mail_index_record *rec;
+	uint32_t cache_flags;
 
 	struct istream *stream, *filter_stream;
 	struct message_size hdr_size, body_size;

Index: index-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- index-storage.c	15 Aug 2004 03:40:32 -0000	1.62
+++ index-storage.c	4 Sep 2004 10:27:30 -0000	1.63
@@ -11,6 +11,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
+#define DEFAULT_CACHE_FIELDS "flags"
 #define DEFAULT_NEVER_CACHE_FIELDS "imap.envelope"
 
 /* How many seconds to keep index opened for reuse after it's been closed */
@@ -199,13 +200,16 @@
 
 static void index_cache_register_defaults(struct mail_cache *cache)
 {
-	const char *never_env;
+	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;
 
-	set_cache_decisions("mail_cache_fields", getenv("MAIL_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 |



More information about the dovecot-cvs mailing list