]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sys: add new log message for kernel status reset after leap second
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 27 Jul 2015 10:24:13 +0000 (12:24 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 27 Jul 2015 10:35:21 +0000 (12:35 +0200)
When a leap second is applied by the kernel, it doesn't actually clear
the STA_INS|STA_DEL bits from the status word, but the state returned
by ntp_adjtime()/adjtimex() is TIME_WAIT until the application clears
the bits.

Add "System clock status reset after leap second" log message for this
case.

sys_linux.c
wrap_adjtimex.c
wrap_adjtimex.h

index e5ca9a61dbf235c4361a260303a6bc70fe5b67c8..fc0249a26e3c61e2c7418092bbac58a2f6eca498 100644 (file)
@@ -177,9 +177,9 @@ read_frequency(void)
 static void
 set_leap(int leap)
 {
-  int current_leap;
+  int current_leap, applied;
 
-  if (TMX_GetLeap(&current_leap) < 0) {
+  if (TMX_GetLeap(&current_leap, &applied) < 0) {
     LOG_FATAL(LOGF_SysLinux, "adjtimex() failed in set_leap");
   }
 
@@ -190,8 +190,9 @@ set_leap(int leap)
     LOG_FATAL(LOGF_SysLinux, "adjtimex() failed in set_leap");
   }
 
-  LOG(LOGS_INFO, LOGF_SysLinux, "System clock status set to %s leap second",
-     leap ? (leap > 0 ? "insert" : "delete") : "not insert/delete");
+  LOG(LOGS_INFO, LOGF_SysLinux, "System clock status %s leap second",
+     leap ? (leap > 0 ? "set to insert" : "set to delete") :
+            (applied ? "reset after" : "set to not insert/delete"));
 }
 
 /* ================================================== */
index 50c4ab73615311caf8ea36cd7017a05e43b16041..ce6f2679259afa9c83501c30765ba02616da8105 100644 (file)
@@ -124,24 +124,25 @@ TMX_SetLeap(int leap)
 }
 
 int
-TMX_GetLeap(int *leap)
+TMX_GetLeap(int *leap, int *applied)
 {
   struct timex txc;
+  int state;
 
   txc.modes = 0;
-  if (adjtimex(&txc) < 0)
+  state = adjtimex(&txc);
+  if (state < 0)
     return -1;
 
-  status &= ~(STA_INS | STA_DEL);
-  status |= txc.status & (STA_INS | STA_DEL);
-
-  if (status & STA_INS)
+  if (txc.status & STA_INS)
     *leap = 1;
-  else if (status & STA_DEL)
+  else if (txc.status & STA_DEL)
     *leap = -1;
   else
     *leap = 0;
 
+  *applied = state == TIME_WAIT;
+
   return 0;
 }
 
index 23587a3d6c6b8d563c6a1eb58442aad29b6c808d..217d06088f46eab0dea4697bdcae2489b55d792d 100644 (file)
@@ -31,7 +31,7 @@ int TMX_ResetOffset(void);
 int TMX_SetFrequency(double *freq, long tick);
 int TMX_GetFrequency(double *freq, long *tick);
 int TMX_SetLeap(int leap);
-int TMX_GetLeap(int *leap);
+int TMX_GetLeap(int *leap, int *applied);
 int TMX_SetSync(int sync, double est_error, double max_error);
 int TMX_TestStepOffset(void);
 int TMX_ApplyStepOffset(double offset);