[dovecot-cvs] dovecot/src/lib-index mail-index.h,1.45,1.46

cras at procontrol.fi cras at procontrol.fi
Sat Oct 26 23:38:39 EEST 2002


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

Modified Files:
	mail-index.h 
Log Message:
mbox locking fixes / changes. we now read-lock the mbox file before syncing
so we can be sure no-one corrupts our reads by expunging mailbox. mbox file
is kept open all the time, but re-opened when device/inode for file has
changed (ie. someone overwrote it). File is also kept mmap()ed until lock is
dropped.

we currently create .lock file even when reading the file (ie. being
effectively write-lock), but that'll be made configurable later.



Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- mail-index.h	23 Oct 2002 19:49:23 -0000	1.45
+++ mail-index.h	26 Oct 2002 19:38:37 -0000	1.46
@@ -316,10 +316,20 @@
 	unsigned int sync_id;
 
 	char *mbox_path; /* mbox-specific path to the actual mbox file */
-	uoff_t mbox_size; /* last synced size of mbox file */
 	int mbox_fd;
-	int mbox_locks;
-	int mbox_lock_type;
+	IBuffer *mbox_inbuf;
+	MailLockType mbox_lock_type;
+	MailLockType mbox_lock_next_sync;
+
+	/* these counters can be used to check that we've synced the mailbox
+	   after locking it */
+	unsigned int mbox_lock_counter;
+	unsigned int mbox_sync_counter;
+
+	/* last mbox sync: */
+	uoff_t mbox_size;
+	dev_t mbox_dev;
+	ino_t mbox_ino;
 
 	int fd; /* opened index file */
 	char *error; /* last error message */
@@ -328,13 +338,11 @@
 	size_t mmap_used_length;
 	size_t mmap_full_length;
 
-        MailLockType lock_type;
-
 	MailIndexHeader *header;
-	unsigned int first_recent_uid;
 
-	unsigned int modifylog_id;
+        MailLockType lock_type;
 	time_t file_sync_stamp;
+	unsigned int first_recent_uid;
 
 	/* these fields are OR'ed to the fields in index header once we
 	   get around grabbing exclusive lock */
@@ -353,7 +361,7 @@
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
-	0
+	0, 0, 0, 0, 0
 
 /* defaults - same as above but prefixed with mail_index_. */
 int mail_index_open(MailIndex *index, int update_recent, int fast);




More information about the dovecot-cvs mailing list