[dovecot-cvs] dovecot/src/lib-index mail-index-lock.c,1.43,1.44

cras at dovecot.org cras at dovecot.org
Tue Oct 4 00:23:25 EEST 2005


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

Modified Files:
	mail-index-lock.c 
Log Message:
Default lock_method to flock instead of fcntl. This is at least useful for
not allowing Dovecot's indexes to be used accidentally with wrong settings
in NFS mounted partitions.



Index: mail-index-lock.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-lock.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- mail-index-lock.c	30 Sep 2005 18:25:30 -0000	1.43
+++ mail-index-lock.c	3 Oct 2005 21:23:23 -0000	1.44
@@ -75,8 +75,7 @@
 			errno = EAGAIN;
 			return 0;
 		}
-		mail_index_file_set_syscall_error(index, path,
-						  "mail_index_lock_fd()");
+		mail_index_file_set_syscall_error(index, path, "fcntl()");
 		return -1;
 #endif
 	}
@@ -109,8 +108,17 @@
 			   b) timeouted */
 			return 0;
 		}
-		mail_index_file_set_syscall_error(index, path,
-						  "mail_index_lock_fd()");
+		if (errno == ENOLCK) {
+			/* Give a bit more helpful error message since this
+			   is the default locking method and it doesn't work
+			   with NFS. */
+			mail_index_set_error(index,
+				"flock() failed with file %s: %m "
+				"(see lock_method setting in config file)",
+				path);
+			return -1;
+		}
+		mail_index_file_set_syscall_error(index, path, "flock()");
 		return -1;
 #endif
 	}



More information about the dovecot-cvs mailing list