[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c, 1.141, 1.142 mbox-storage.h, 1.42, 1.43

cras at dovecot.org cras at dovecot.org
Sun Apr 9 18:50:32 EEST 2006


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

Modified Files:
	mbox-storage.c mbox-storage.h 
Log Message:
Added MAILBOX_OPEN_KEEP_LOCKED flag to mailbox opening and implemented it
for mbox and maildir. It keeps the mailbox locked the whole time until
mailbox_close() is called.



Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -d -r1.141 -r1.142
--- mbox-storage.c	1 Apr 2006 09:36:25 -0000	1.141
+++ mbox-storage.c	9 Apr 2006 15:50:29 -0000	1.142
@@ -606,6 +606,15 @@
 		}
 	}
 
+	if (mbox->ibox.keep_locked) {
+		if (mbox_lock(mbox, F_WRLCK, &mbox->mbox_global_lock_id) <= 0) {
+			struct mailbox *box = &mbox->ibox.box;
+
+			mailbox_close(&box);
+			return NULL;
+		}
+	}
+
 	return &mbox->ibox.box;
 }
 
@@ -1039,6 +1048,9 @@
 			ret = -1;
 	}
 
+	if (mbox->mbox_global_lock_id != 0)
+		(void)mbox_unlock(mbox, mbox->mbox_global_lock_id);
+
         mbox_file_close(mbox);
 	if (mbox->mbox_file_stream != NULL)
 		i_stream_destroy(&mbox->mbox_file_stream);

Index: mbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- mbox-storage.h	1 Apr 2006 09:36:25 -0000	1.42
+++ mbox-storage.h	9 Apr 2006 15:50:29 -0000	1.43
@@ -34,7 +34,7 @@
 	ino_t mbox_ino;
 	unsigned int mbox_excl_locks, mbox_shared_locks;
 	struct dotlock *mbox_dotlock;
-	unsigned int mbox_lock_id;
+	unsigned int mbox_lock_id, mbox_global_lock_id;
 	bool mbox_readonly, mbox_writeonly;
 	time_t mbox_dirty_stamp;
 	off_t mbox_dirty_size;



More information about the dovecot-cvs mailing list