summaryrefslogtreecommitdiff
path: root/usr.sbin/cron/cron.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-02-20 02:03:20 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-02-20 02:03:20 +0000
commit603c6d00f9181f4aa96463083c980218ec2e5594 (patch)
tree9328bd0f9429a0b05ea4c9e2efc3caee0898dba6 /usr.sbin/cron/cron.c
parent86744021bc298d5866b29e263475344195783db9 (diff)
Turn get_gmtoff into a macro for OSes with tm_gmtoff (like OpenBSD).
Save the GMT offset in a global so cron_sleep can use it. This means the offset can only change in set_time() which is really what we want.
Diffstat (limited to 'usr.sbin/cron/cron.c')
-rw-r--r--usr.sbin/cron/cron.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c
index b12cb33fc82..3ada164920a 100644
--- a/usr.sbin/cron/cron.c
+++ b/usr.sbin/cron/cron.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cron.c,v 1.11 2001/02/19 14:33:32 millert Exp $ */
+/* $OpenBSD: cron.c,v 1.12 2001/02/20 02:03:19 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
*/
@@ -21,7 +21,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static char rcsid[] = "$OpenBSD: cron.c,v 1.11 2001/02/19 14:33:32 millert Exp $";
+static char rcsid[] = "$OpenBSD: cron.c,v 1.12 2001/02/20 02:03:19 millert Exp $";
#endif
#define MAIN_PROGRAM
@@ -40,6 +40,7 @@ static void usage(void),
static int got_sighup, got_sigchld;
static int timeRunning, virtualTime, clockTime;
+static long GMToff;
static void
usage(void) {
@@ -314,7 +315,6 @@ find_jobs(int vtime, cron_db *db, int doWild, int doNonWild) {
static void
set_time(int initialize) {
struct tm *tm;
- static long gmtoff;
static int isdst;
StartTime = time(NULL);
@@ -323,9 +323,9 @@ set_time(int initialize) {
tm = localtime(&StartTime);
if (initialize || tm->tm_isdst != isdst) {
isdst = tm->tm_isdst;
- gmtoff = get_gmtoff(&StartTime);
+ GMToff = get_gmtoff(&StartTime, tm);
}
- clockTime = (StartTime + gmtoff) / (time_t)SECONDS_PER_MINUTE;
+ clockTime = (StartTime + GMToff) / (time_t)SECONDS_PER_MINUTE;
}
/*
@@ -334,12 +334,9 @@ set_time(int initialize) {
static void
cron_sleep(int target) {
time_t t;
- struct tm *tm;
int seconds_to_wait;
- t = time(NULL);
- tm = localtime(&t);
- t += tm->tm_gmtoff;
+ t = time(NULL) + GMToff;
seconds_to_wait = (int)(target * SECONDS_PER_MINUTE - t) + 1;
Debug(DSCH, ("[%ld] Target time=%ld, sec-to-wait=%d\n",
(long)getpid(), (long)target*SECONDS_PER_MINUTE, seconds_to_wait))