[dovecot-cvs] dovecot/src/lib file-dotlock.c,1.13,1.14

cras at procontrol.fi cras at procontrol.fi
Sun May 30 00:40:33 EEST 2004


Update of /home/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv30244/lib

Modified Files:
	file-dotlock.c 
Log Message:
Removed hardcoded mechanism lists. It's now possible to add them
dynamically. Added support for SASL initial response.



Index: file-dotlock.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/file-dotlock.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- a/file-dotlock.c	16 May 2004 23:16:23 -0000	1.13
+++ b/file-dotlock.c	29 May 2004 21:40:30 -0000	1.14
@@ -371,13 +371,27 @@
 		return -1;
 	}
 
+	dotlock_r->dev = st.st_dev;
+	dotlock_r->ino = st.st_ino;
+
 	if (close(fd) < 0) {
 		i_error("fstat(%s) failed: %m", lock_path);
 		return -1;
 	}
 
-	dotlock_r->dev = st.st_dev;
-	dotlock_r->ino = st.st_ino;
+	/* some NFS implementations may have used cached mtime in previous
+	   fstat() call. Check again to avoid "dotlock was modified" errors. */
+	if (stat(lock_path, &st) < 0) {
+		i_error("stat(%s) failed: %m", lock_path);
+		return -1;
+	}
+	/* extra sanity check won't hurt.. */
+	if (st.st_dev != dotlock_r->dev ||
+	    st.st_ino != dotlock_r->ino) {
+		i_error("dotlock %s was immediately recreated under us",
+			lock_path);
+		return -1;
+	}
 	dotlock_r->mtime = st.st_mtime;
 	return 1;
 }



More information about the dovecot-cvs mailing list