[ntpsec commit] Repair incorrectly transpanted LEAP_SMEAR code [Bug 2855].

Eric S. Raymond esr at ntpsec.org
Fri Oct 23 10:32:04 UTC 2015


Module:    ntpsec
Branch:    master
Commit:    d1065a6ac88c623ec07039b1026ad6ab1d65ab00
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=d1065a6ac88c623ec07039b1026ad6ab1d65ab00

Author:    Eric S. Raymond <esr at thyrsus.com>
Date:      Fri Oct 23 06:31:55 2015 -0400

Repair incorrectly transpanted LEAP_SMEAR code [Bug 2855].

---

 ntpd/ntp_timer.c | 56 ++++++++++++++++++++++++++++++--------------------------
 1 file changed, 30 insertions(+), 26 deletions(-)

diff --git a/ntpd/ntp_timer.c b/ntpd/ntp_timer.c
index b6baa91..5c37a68 100644
--- a/ntpd/ntp_timer.c
+++ b/ntpd/ntp_timer.c
@@ -488,7 +488,9 @@ check_leapsec(
 		lsprox = LSPROX_NOWARN;
 		leapsec_reset_frame();
 		memset(&lsdata, 0, sizeof(lsdata));
-	} else if (leapsec_query(&lsdata, now, tpiv)) {
+	} else {
+		int fired = leapsec_query(&lsdata, now, tpiv);
+
 		DPRINTF(1, ("*** leapsec_query: fired %i, now %u (0x%08X), tai_diff %i, ddist %u\n",
 		      fired, now, now, lsdata.tai_diff, lsdata.ddist));
 #ifdef ENABLE_LEAP_SMEAR
@@ -558,33 +560,35 @@ check_leapsec(
 		/* Full hit. Eventually step the clock, but always
 		 * announce the leap event has happened.
 		 */
-		const char *leapmsg = NULL;
-		if (lsdata.warped < 0) {
-			if (clock_max_back > 0.0 &&
-			    clock_max_back < fabs(lsdata.warped)) {
-				step_systime(lsdata.warped);
-				leapmsg = leapmsg_p_step;
-			} else {
-				leapmsg = leapmsg_p_slew;
-			}
-		} else 	if (lsdata.warped > 0) {
-			if (clock_max_fwd > 0.0 &&
-			    clock_max_fwd < fabs(lsdata.warped)) {
-				step_systime(lsdata.warped);
-				leapmsg = leapmsg_n_step;
-			} else {
-				leapmsg = leapmsg_n_slew;
+	  	if (fired) {
+			const char *leapmsg = NULL;
+			if (lsdata.warped < 0) {
+				if (clock_max_back > 0.0 &&
+				    clock_max_back < fabs(lsdata.warped)) {
+					step_systime(lsdata.warped);
+					leapmsg = leapmsg_p_step;
+				} else {
+					leapmsg = leapmsg_p_slew;
+				}
+			} else 	if (lsdata.warped > 0) {
+				if (clock_max_fwd > 0.0 &&
+				    clock_max_fwd < fabs(lsdata.warped)) {
+					step_systime(lsdata.warped);
+					leapmsg = leapmsg_n_step;
+				} else {
+					leapmsg = leapmsg_n_slew;
+				}
 			}
+			if (leapmsg)
+				msyslog(LOG_NOTICE, "%s", leapmsg);
+			report_event(EVNT_LEAP, NULL, NULL);
+			lsprox  = LSPROX_NOWARN;
+			leapsec = LSPROX_NOWARN;
+			sys_tai = lsdata.tai_offs;
+		} else {
+			lsprox  = lsdata.proximity;
+			sys_tai = lsdata.tai_offs;
 		}
-		if (leapmsg)
-			msyslog(LOG_NOTICE, "%s", leapmsg);
-		report_event(EVNT_LEAP, NULL, NULL);
-		lsprox  = LSPROX_NOWARN;
-		leapsec = LSPROX_NOWARN;
-		sys_tai = lsdata.tai_offs;
-	} else {
-		lsprox  = lsdata.proximity;
-		sys_tai = lsdata.tai_offs;
 	}
 
 	/* We guard against panic alarming during the red alert phase.



More information about the vc mailing list