[dovecot-cvs] dovecot/src/lib-index mail-cache-compress.c, 1.37, 1.38 mail-cache-private.h, 1.26, 1.27 mail-cache.c, 1.73, 1.74 mail-index.c, 1.212, 1.213 mail-index.h, 1.150, 1.151

cras at dovecot.org cras at dovecot.org
Fri Jan 6 16:21:24 EET 2006


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

Modified Files:
	mail-cache-compress.c mail-cache-private.h mail-cache.c 
	mail-index.c mail-index.h 
Log Message:
Moved uoff_t and time_t compatibility checks to cache file, since they're
not needed for index/log. Only index file incompatibility check is now
endianess flag.



Index: mail-cache-compress.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-compress.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- mail-cache-compress.c	30 Sep 2005 18:46:30 -0000	1.37
+++ mail-cache-compress.c	6 Jan 2006 14:21:21 -0000	1.38
@@ -144,6 +144,8 @@
 
 	memset(&hdr, 0, sizeof(hdr));
 	hdr.version = MAIL_CACHE_VERSION;
+	hdr.compat_sizeof_uoff_t = sizeof(uoff_t);
+	hdr.compat_sizeof_time_t = sizeof(time_t);
 	hdr.indexid = idx_hdr->indexid;
 	hdr.file_seq = get_next_file_seq(cache, view);
 	o_stream_send(output, &hdr, sizeof(hdr));

Index: mail-cache-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-private.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mail-cache-private.h	30 Sep 2005 18:46:30 -0000	1.26
+++ mail-cache-private.h	6 Jan 2006 14:21:21 -0000	1.27
@@ -44,7 +44,9 @@
 	/* version is increased only when you can't have backwards
 	   compatibility. */
 	uint8_t version;
-	uint8_t unused[3];
+	uint8_t compat_sizeof_uoff_t;
+	uint8_t compat_sizeof_time_t;
+	uint8_t unused;
 
 	uint32_t indexid;
 	uint32_t file_seq;

Index: mail-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- mail-cache.c	30 Sep 2005 18:46:30 -0000	1.73
+++ mail-cache.c	6 Jan 2006 14:21:21 -0000	1.74
@@ -126,6 +126,19 @@
 		/* version changed - upgrade silently */
 		return FALSE;
 	}
+	if (hdr->compat_sizeof_uoff_t != sizeof(uoff_t) ||
+	    hdr->compat_sizeof_time_t != sizeof(time_t)) {
+		if (hdr->compat_sizeof_uoff_t == 0 &&
+		    hdr->compat_sizeof_time_t == 0) {
+			/* FIXME: keep backwards compatibility for a while.
+			   set hdr_modified=TRUE so header gets fixed the next
+			   time cache is locked. */
+			cache->hdr_modified = TRUE;
+		} else {
+			/* architecture change - handle silently(?) */
+			return -1;
+		}
+	}
 
 	if (cache->hdr->indexid != cache->index->indexid) {
 		/* index id changed */
@@ -456,6 +469,10 @@
 	}
 
 	if (cache->hdr_modified) {
+		/* FIXME: for backwards compatibility - keep them for a while */
+		cache->hdr_copy.compat_sizeof_uoff_t = sizeof(uoff_t);
+		cache->hdr_copy.compat_sizeof_time_t = sizeof(time_t);
+
 		cache->hdr_modified = FALSE;
 		if (mail_cache_write(cache, &cache->hdr_copy,
 				     sizeof(cache->hdr_copy), 0) < 0)

Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.212
retrieving revision 1.213
diff -u -d -r1.212 -r1.213
--- mail-index.c	6 Jan 2006 14:06:23 -0000	1.212
+++ mail-index.c	6 Jan 2006 14:21:21 -0000	1.213
@@ -492,20 +492,17 @@
 				   struct mail_index_map *map)
 {
 	const struct mail_index_header *hdr = &map->hdr;
-	unsigned char compat_data[sizeof(hdr->compat_data)];
+        enum mail_index_header_compat_flags compat_flags = 0;
 
-	memset(compat_data, 0, sizeof(compat_data));
 #ifndef WORDS_BIGENDIAN
-	compat_data[0] = MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
+	compat_flags |= MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
 #endif
-	compat_data[1] = sizeof(uoff_t);
-	compat_data[2] = sizeof(time_t);
 
 	if (hdr->major_version != MAIL_INDEX_MAJOR_VERSION) {
 		/* major version change - handle silently(?) */
 		return -1;
 	}
-	if (memcmp(hdr->compat_data, compat_data, sizeof(compat_data)) != 0) {
+	if (hdr->compat_flags != compat_flags) {
 		/* architecture change - handle silently(?) */
 		return -1;
 	}
@@ -1350,10 +1347,8 @@
 	hdr->record_size = sizeof(struct mail_index_record);
 
 #ifndef WORDS_BIGENDIAN
-	hdr->compat_data[0] = MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
+	hdr->compat_flags |= MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
 #endif
-	hdr->compat_data[1] = sizeof(uoff_t);
-	hdr->compat_data[2] = sizeof(time_t);
 
 	hdr->indexid = now;
 

Index: mail-index.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -d -r1.150 -r1.151
--- mail-index.h	29 Apr 2005 12:02:34 -0000	1.150
+++ mail-index.h	6 Jan 2006 14:21:21 -0000	1.151
@@ -67,11 +67,8 @@
 	uint32_t header_size; /* base + extended header size */
 	uint32_t record_size;
 
-	/* 0 = flags
-	   1 = sizeof(uoff_t)
-	   2 = sizeof(time_t)
-	   3 = unused */
-	uint8_t compat_data[4];
+	uint8_t compat_flags; /* enum mail_index_header_compat_flags */
+	uint8_t unused[3];
 
 	uint32_t indexid;
 	uint32_t flags;



More information about the dovecot-cvs mailing list