[dovecot-cvs] dovecot/src/lib-index mail-cache.c,1.7,1.8 mail-cache.h,1.4,1.5 mail-index.c,1.98,1.99 mail-index.h,1.91,1.92

cras at procontrol.fi cras at procontrol.fi
Wed Sep 3 02:33:35 EEST 2003


Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv25812/lib-index

Modified Files:
	mail-cache.c mail-cache.h mail-index.c mail-index.h 
Log Message:
mbox reading is kind of working again. Just don't try rewriting or expunging
:) Changing headers are also hidden from clients so mbox messages are finally
seen immutable as required by IMAP.



Index: mail-cache.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-cache.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mail-cache.c	22 Aug 2003 18:57:00 -0000	1.7
+++ mail-cache.c	2 Sep 2003 22:33:33 -0000	1.8
@@ -109,8 +109,9 @@
 	sizeof(struct mail_sent_date),
 	sizeof(time_t),
 	sizeof(uoff_t),
+	sizeof(uoff_t),
 
-	0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
 
 	/* variable sized */
 	(unsigned int)-1, (unsigned int)-1, (unsigned int)-1, (unsigned int)-1,
@@ -1758,6 +1759,26 @@
 	}
 
 	memcpy(data, &flags, sizeof(flags));
+	return TRUE;
+}
+
+int mail_cache_update_location_offset(struct mail_cache *cache,
+				      struct mail_index_record *rec,
+				      uoff_t offset)
+{
+	void *data;
+	size_t size;
+
+	i_assert(cache->locks > 0);
+
+	if (!cache_lookup_field(cache, rec, MAIL_CACHE_LOCATION_OFFSET,
+				&data, &size)) {
+		mail_cache_set_corrupted(cache,
+			"Missing location offset for record %u", rec->uid);
+		return FALSE;
+	}
+
+	memcpy(data, &offset, sizeof(offset));
 	return TRUE;
 }
 

Index: mail-cache.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-cache.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mail-cache.h	24 Aug 2003 07:03:22 -0000	1.4
+++ mail-cache.h	2 Sep 2003 22:33:33 -0000	1.5
@@ -17,6 +17,7 @@
 	MAIL_CACHE_SENT_DATE		= 0x00000008,
 	MAIL_CACHE_RECEIVED_DATE	= 0x00000010,
 	MAIL_CACHE_VIRTUAL_FULL_SIZE	= 0x00000020,
+	MAIL_CACHE_PHYSICAL_BODY_SIZE	= 0x00000040,
 
 	/* variable sized field */
 	MAIL_CACHE_HEADERS1		= 0x40000000,
@@ -34,7 +35,8 @@
 					  MAIL_CACHE_MD5 |
 					  MAIL_CACHE_SENT_DATE |
 					  MAIL_CACHE_RECEIVED_DATE |
-					  MAIL_CACHE_VIRTUAL_FULL_SIZE,
+					  MAIL_CACHE_VIRTUAL_FULL_SIZE |
+					  MAIL_CACHE_PHYSICAL_BODY_SIZE,
 	MAIL_CACHE_HEADERS_MASK		= MAIL_CACHE_HEADERS1 |
 					  MAIL_CACHE_HEADERS2 |
 					  MAIL_CACHE_HEADERS3 |
@@ -156,6 +158,12 @@
 int mail_cache_update_index_flags(struct mail_cache *cache,
 				  struct mail_index_record *rec,
 				  enum mail_index_record_flag flags);
+
+/* Update location offset. External locking is assumed to take care of locking
+   readers out to prevent race conditions. */
+int mail_cache_update_location_offset(struct mail_cache *cache,
+				      struct mail_index_record *rec,
+				      uoff_t offset);
 
 /* Return the whole file mmaped. */
 void *mail_cache_get_mmaped(struct mail_cache *cache, size_t *size);

Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- mail-index.c	24 Aug 2003 06:32:08 -0000	1.98
+++ mail-index.c	2 Sep 2003 22:33:33 -0000	1.99
@@ -76,6 +76,7 @@
 
 	index->sync_id = hdr->sync_id;
 	index->sync_stamp = hdr->sync_stamp;
+	index->sync_size = hdr->sync_size;
 	index->mmap_used_length = hdr->used_file_size;
 	return TRUE;
 }
@@ -440,8 +441,10 @@
 		keep_fsck = (index->set_flags & MAIL_INDEX_HDR_FLAG_FSCK) != 0;
 		mail_index_update_header_changes(index);
 
-		if (index->sync_dirty_stamp == 0)
+		if (index->sync_dirty_stamp == 0) {
 			index->header->sync_stamp = index->sync_stamp;
+			index->header->sync_size = index->sync_size;
+		}
 
 		/* remove the FSCK flag only after successful fsync() */
 		if (mail_index_sync_file(index) && !keep_fsck) {

Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- mail-index.h	24 Aug 2003 07:06:06 -0000	1.91
+++ mail-index.h	2 Sep 2003 22:33:33 -0000	1.92
@@ -134,6 +134,7 @@
 	uint32_t first_unseen_uid_lowwater;
 	uint32_t first_deleted_uid_lowwater;
 
+	uint64_t sync_size;
 	uint32_t sync_stamp;
 };
 
@@ -298,7 +299,6 @@
 	unsigned int mbox_sync_counter;
 
 	/* last mbox sync: */
-	uoff_t mbox_size;
 	dev_t mbox_dev;
 	ino_t mbox_ino;
 
@@ -320,6 +320,7 @@
 
         enum mail_lock_type lock_type;
 	time_t sync_stamp, sync_dirty_stamp;
+	uoff_t sync_size;
 	time_t next_dirty_flags_flush;
 	unsigned int first_recent_uid;
 



More information about the dovecot-cvs mailing list