Blame SOURCES/at-3.1.20-aborted-jobs.patch

6927e7
diff -up at-3.1.20/atd.c.aborted at-3.1.20/atd.c
6927e7
--- at-3.1.20/atd.c.aborted	2017-09-14 15:31:47.971486148 +0200
6927e7
+++ at-3.1.20/atd.c	2017-09-14 15:43:53.506567281 +0200
6927e7
@@ -731,12 +731,17 @@ run_loop()
6927e7
 	/* Is the file already locked?
6927e7
 	 */
6927e7
 	if (buf.st_nlink > 1) {
6927e7
+	    if (run_time < buf.st_mtime)
6927e7
+		run_time = buf.st_mtime;
6927e7
 	    if (run_time + CHECK_INTERVAL <= now) {
6927e7
-
6927e7
 		/* Something went wrong the last time this was executed.
6927e7
 		 * Let's remove the lockfile and reschedule.
6927e7
+		 * We also change the timestamp to avoid rerunning the job more
6927e7
+		 * than once every CHECK_INTERVAL.
6927e7
 		 */
6927e7
 		strncpy(lock_name, dirent->d_name, sizeof(lock_name));
6927e7
+		if (utime(lock_name, 0) < 0)
6927e7
+			syslog(LOG_ERR, "utime couldn't be set for lock file %s\n", lock_name);
6927e7
 		lock_name[sizeof(lock_name)-1] = '\0';
6927e7
 		lock_name[0] = '=';
6927e7
 		unlink(lock_name);