summaryrefslogtreecommitdiff
path: root/usr.sbin/cron/atrun.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2016-01-11 14:23:51 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2016-01-11 14:23:51 +0000
commitd5e0dfa29205f4b236215fe2454b6ffc7bacec86 (patch)
treeb5e35b646b71b4b27dc5de2c3b4bd85ae5562e89 /usr.sbin/cron/atrun.c
parentebad9f2ea5cde3598dec641799e5ea4d09a67585 (diff)
When caching the mtime of the spool directory and system crontab files,
stash a struct timespec, not just a time_t. Fixes a bug where cron could skip re-reading the spool after two consecutive changes.
Diffstat (limited to 'usr.sbin/cron/atrun.c')
-rw-r--r--usr.sbin/cron/atrun.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c
index 95f6fbe70ba..78798b960ff 100644
--- a/usr.sbin/cron/atrun.c
+++ b/usr.sbin/cron/atrun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atrun.c,v 1.42 2015/11/17 22:31:44 millert Exp $ */
+/* $OpenBSD: atrun.c,v 1.43 2016/01/11 14:23:50 millert Exp $ */
/*
* Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <sys/wait.h>
#include <bitstring.h> /* for structs.h */
@@ -91,7 +92,7 @@ scan_atjobs(at_db **db, struct timespec *ts)
close(dfd);
return (0);
}
- if (old_db != NULL && old_db->mtime == sb.st_mtime) {
+ if (old_db != NULL && timespeccmp(&old_db->mtime, &sb.st_mtim, ==)) {
close(dfd);
return (0);
}
@@ -106,7 +107,7 @@ scan_atjobs(at_db **db, struct timespec *ts)
closedir(atdir);
return (0);
}
- new_db->mtime = sb.st_mtime; /* stash at dir mtime */
+ new_db->mtime = sb.st_mtim; /* stash at dir mtime */
TAILQ_INIT(&new_db->jobs);
pending = 0;