[dovecot-cvs] dovecot/src/lib file-dotlock.c,1.20,1.21

cras at dovecot.org cras at dovecot.org
Tue Dec 7 02:41:40 EET 2004


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

Modified Files:
	file-dotlock.c 
Log Message:
If pid in dotlock file is same as ours, assume a stale lock file.



Index: file-dotlock.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/file-dotlock.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- file-dotlock.c	11 Oct 2004 13:05:24 -0000	1.20
+++ file-dotlock.c	7 Dec 2004 00:41:38 -0000	1.21
@@ -131,8 +131,13 @@
 
 	if (lock_info->have_pid) {
 		/* we've local PID. Check if it exists. */
-		if (kill(pid, 0) == 0 || errno != ESRCH)
-			return 0;
+		if (kill(pid, 0) == 0 || errno != ESRCH) {
+			if (pid != getpid())
+				return 0;
+			/* it's us. either we're locking it again, or it's a
+			   stale lock file with same pid than us. either way,
+			   recreate it.. */
+		}
 
 		/* doesn't exist - go ahead and delete */
 		if (unlink(lock_info->lock_path) < 0 && errno != ENOENT) {



More information about the dovecot-cvs mailing list