]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2326] More leapsecond file notification cleanup
authorHarlan Stenn <stenn@ntp.org>
Mon, 25 Nov 2013 12:01:41 +0000 (04:01 -0800)
committerHarlan Stenn <stenn@ntp.org>
Mon, 25 Nov 2013 12:01:41 +0000 (04:01 -0800)
bk: 52933c253x_5svXtClsTl1GfjBaWeg

ntpd/ntp_config.c
ntpd/ntp_io.c
ntpd/ntp_timer.c

index 3ae71a9b423e6c829aa225b3a384796f81839d74..9780fcb7040d35ed557b61f506746f5c00c58454 100644 (file)
@@ -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
 /*
index fde2baf4389120522571b1ee84bf56d788e7a89c..1668585762ce55660d7248f7b5c6419fd74cdc2a 100644 (file)
@@ -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 */
index 129d75cd8b172fe91d0fc12f879eebb63b799c10..379a2391d8168b9ac54b25e2a89ae06280402baf 100644 (file)
@@ -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;
+               }
        }
 }