[dovecot-cvs] dovecot/src/lib file-dotlock.c,1.26,1.27

cras at dovecot.org cras at dovecot.org
Fri Sep 16 15:30:11 EEST 2005


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

Modified Files:
	file-dotlock.c 
Log Message:
If dotlock is overwritten/deleted, say in the error message how long we kept
the lock.



Index: file-dotlock.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/file-dotlock.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- file-dotlock.c	28 Aug 2005 19:28:55 -0000	1.26
+++ file-dotlock.c	16 Sep 2005 12:30:08 -0000	1.27
@@ -28,6 +28,8 @@
 
 	char *path;
 	int fd;
+
+	time_t lock_time;
 };
 
 struct lock_info {
@@ -423,11 +425,13 @@
 			i_error("fstat(%s) failed: %m", lock_path);
 			ret = -1;
 		} else {
+			/* successful dotlock creation */
 			dotlock->dev = st.st_dev;
 			dotlock->ino = st.st_ino;
 
 			dotlock->path = i_strdup(path);
 			dotlock->fd = lock_info.fd;
+                        dotlock->lock_time = now;
 			lock_info.fd = -1;
 		}
 	}
@@ -524,7 +528,9 @@
 
 	if (lstat(lock_path, &st) < 0) {
 		if (errno == ENOENT) {
-			i_warning("Our dotlock file %s was deleted", lock_path);
+			i_warning("Our dotlock file %s was deleted "
+				  "(kept it %d secs)", lock_path,
+				  (int)(dotlock->lock_time - time(NULL)));
 			file_dotlock_free(dotlock);
 			return 0;
 		}
@@ -536,7 +542,9 @@
 
 	if (dotlock->ino != st.st_ino ||
 	    !CMP_DEV_T(dotlock->dev, st.st_dev)) {
-		i_warning("Our dotlock file %s was overridden", lock_path);
+		i_warning("Our dotlock file %s was overridden "
+			  "(kept it %d secs)", lock_path,
+			  (int)(dotlock->lock_time - time(NULL)));
 		errno = EEXIST;
 		file_dotlock_free(dotlock);
 		return 0;
@@ -544,13 +552,17 @@
 
 	if (dotlock->mtime != st.st_mtime && dotlock->fd == -1) {
 		i_warning("Our dotlock file %s was modified (%s vs %s), "
-			  "assuming it wasn't overridden", lock_path,
-			  dec2str(dotlock->mtime), dec2str(st.st_mtime));
+			  "assuming it wasn't overridden (kept it %d secs)",
+			  lock_path,
+			  dec2str(dotlock->mtime), dec2str(st.st_mtime),
+			  (int)(dotlock->lock_time - time(NULL)));
 	}
 
 	if (unlink(lock_path) < 0) {
 		if (errno == ENOENT) {
-			i_warning("Our dotlock file %s was deleted", lock_path);
+			i_warning("Our dotlock file %s was deleted "
+				  "(kept it %d secs)", lock_path,
+				  (int)(dotlock->lock_time - time(NULL)));
 			file_dotlock_free(dotlock);
 			return 0;
 		}
@@ -616,8 +628,9 @@
 
 		if (st.st_ino != st2.st_ino ||
 		    !CMP_DEV_T(st.st_dev, st2.st_dev)) {
-			i_warning("Our dotlock file %s was overridden",
-				  lock_path);
+			i_warning("Our dotlock file %s was overridden "
+				  "(kept it %u secs)", lock_path,
+				  dotlock->lock_time - time(NULL));
 			errno = EEXIST;
 			file_dotlock_free(dotlock);
 			return 0;



More information about the dovecot-cvs mailing list