From: Harlan Stenn Date: Mon, 25 Nov 2013 12:01:41 +0000 (-0800) Subject: [Bug 2326] More leapsecond file notification cleanup X-Git-Tag: NTP_4_2_7P398~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c09236bc677f3417afc56ed52084c01e9b5d2a41;p=thirdparty%2Fntp.git [Bug 2326] More leapsecond file notification cleanup bk: 52933c253x_5svXtClsTl1GfjBaWeg --- diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 3ae71a9b4..9780fcb70 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -191,7 +191,6 @@ int cryptosw; /* crypto command called */ extern int sys_maxclock; extern char *stats_drift_file; /* name of the driftfile */ -extern char *leapseconds_file; /*name of the leapseconds file */ #ifdef BC_LIST_FRAMEWORK_NOT_YET_USED /* diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index fde2baf43..166858576 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -151,9 +151,6 @@ volatile u_long handler_calls; /* number of calls to interrupt handler */ volatile u_long handler_pkts; /* number of pkts received by handler */ u_long io_timereset; /* time counters were reset */ -time_t check_leapfile; -#define CHECK_LEAP_EVERY 86400 - /* * Interface stuff */ @@ -427,8 +424,6 @@ collect_timing(struct recvbuf *rb, const char *tag, int count, l_fp *dts) void init_io(void) { - check_leapfile = time(NULL) + CHECK_LEAP_EVERY; - /* Init buffer free list and stat counters */ init_recvbuff(RECV_INIT); /* update interface every 5 minutes as default */ @@ -3737,33 +3732,6 @@ input_handler( #endif /* DEBUG_TIMING */ /* We're done... */ ih_return: - if (check_leapfile < time(NULL)) { - int clf; - - check_leapfile += CHECK_LEAP_EVERY; - clf = check_leap_file(); - - /* - ** check_leap_file() returns -1 on a problem, - ** 0 on an expired leapsecond file, or the number - ** of days until the leapsecond file expires. - */ - if (-1 == clf) { - /* nothing to do */ - } else if (0 == clf) { - /* XXX: Do we want to report_event() here? */ - // report_event(EVNT_LEAPVAL, NULL, NULL); - if (leap_warn_log == FALSE) { - msyslog(LOG_WARNING, - "input_handler: leapseconds data file <%s> has expired!", - leapseconds_file); - leap_warn_log = TRUE; - } - } else if (clf < 31) { - msyslog(LOG_WARNING, - "input_handler: leapseconds data file <%s> will expire in less than %d days' time.", leapseconds_file, clf); - } - } return; } #endif /* !HAVE_IO_COMPLETION_PORT */ diff --git a/ntpd/ntp_timer.c b/ntpd/ntp_timer.c index 129d75cd8..379a2391d 100644 --- a/ntpd/ntp_timer.c +++ b/ntpd/ntp_timer.c @@ -40,6 +40,8 @@ #define TC_ERR (-1) #endif +extern char *leapseconds_file; /*name of the leapseconds file */ + static void check_leapsec(u_int32, const time_t*, int/*BOOL*/); /* @@ -65,6 +67,8 @@ volatile int alarm_flag; static u_long interface_timer; /* interface update timer */ static u_long adjust_timer; /* second timer */ static u_long stats_timer; /* stats timer */ +time_t check_leapfile = 0; /* Report leapfile problems once/day */ +#define CHECK_LEAP_EVERY 86400 static u_long huffpuff_timer; /* huff-n'-puff timer */ static u_long worker_idle_timer;/* next check for idle intres */ u_long leapsec; /* seconds to next leap (proximity class) */ @@ -284,7 +288,6 @@ timer(void) struct peer * next_peer; l_fp now; time_t tnow; - static int leap_warn_log = FALSE; /* * The basic timerevent is one second. This is used to adjust the @@ -417,7 +420,8 @@ timer(void) worker_idle_timer_fired(); /* - * Finally, write hourly stats. + * Finally, write hourly stats and do the hourly + * and daily leapfile checks. */ if (stats_timer <= current_time) { stats_timer += HOUR; @@ -429,23 +433,24 @@ timer(void) ** check_leap_file() returns -1 on a problem, ** 0 on an expired leapsecond file, or the number ** of days until the leapsecond file expires. + ** + ** We only want to log stuff once/day. */ - if (-1 == clf) { - /* nothing to do */ - } else if (0 == clf) { - report_event(EVNT_LEAPVAL, NULL, NULL); - if (leap_warn_log == FALSE) { + if (check_leapfile < current_time) { + check_leapfile += CHECK_LEAP_EVERY; + if (-1 == clf) { + /* nothing to do */ + } else if (0 == clf) { + report_event(EVNT_LEAPVAL, NULL, NULL); msyslog(LOG_WARNING, "timer: leapseconds data file <%s> has expired!", leapseconds_file); - leap_warn_log = TRUE; + } else if (clf < 31) { + msyslog(LOG_WARNING, + "timer: leapseconds data file <%s> will expire in less than %d days' time.", leapseconds_file, clf); } - } else if (clf < 31) { - msyslog(LOG_WARNING, - "timer: leapseconds data file <%s> will expire in less than %d days' time.", leapseconds_file, clf); } - } else - leap_warn_log = FALSE; + } } }