[dovecot-cvs] dovecot/src/lib-storage/index index-storage.c, 1.64, 1.65

cras at dovecot.org cras at dovecot.org
Sun Oct 10 20:25:47 EEST 2004


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

Modified Files:
	index-storage.c 
Log Message:
Replaced fcntl_locks_disable with lock_method, so it's now possible to use
flock() to lock indexes.



Index: index-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- index-storage.c	4 Sep 2004 12:44:14 -0000	1.64
+++ index-storage.c	10 Oct 2004 17:25:44 -0000	1.65
@@ -284,6 +284,8 @@
 {
 	struct index_mailbox *ibox;
 	enum mail_index_open_flags index_flags;
+	enum mail_index_lock_method lock_method = 0;
+	const char *str;
 
 	i_assert(name != NULL);
 
@@ -296,8 +298,16 @@
 	if (getenv("MMAP_NO_WRITE") != NULL)
 #endif
 		index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_NO_WRITE;
-	if (getenv("FCNTL_LOCKS_DISABLE") != NULL)
-		index_flags |= MAIL_INDEX_OPEN_FLAG_FCNTL_LOCKS_DISABLE;
+
+	str = getenv("LOCK_METHOD");
+	if (str == NULL || strcmp(str, "fcntl") == 0)
+		lock_method = MAIL_INDEX_LOCK_FCNTL;
+	else if (strcmp(str, "flock") == 0)
+		lock_method = MAIL_INDEX_LOCK_FLOCK;
+	else if (strcmp(str, "dotlock") == 0)
+		lock_method = MAIL_INDEX_LOCK_DOTLOCK;
+	else
+		i_fatal("Unknown lock_method: %s", str);
 
 	do {
 		ibox = i_new(struct index_mailbox, 1);
@@ -315,7 +325,7 @@
 		ibox->commit_log_file_seq = 0;
 		ibox->mail_read_mmaped = getenv("MAIL_READ_MMAPED") != NULL;
 
-		if (mail_index_open(index, index_flags) < 0)
+		if (mail_index_open(index, index_flags, lock_method) < 0)
 			break;
 
 		ibox->cache = mail_index_get_cache(index);



More information about the dovecot-cvs mailing list