]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sys_linux: always call TMX_SetLeap() in set_leap()
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 26 Aug 2015 12:45:36 +0000 (14:45 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 27 Aug 2015 11:26:12 +0000 (13:26 +0200)
The optimization avoiding unnecessary setting of the kernel leap status
can cause a problem when something outside chronyd sets the status to
the new expected value. There will be no TMX_SetLeap() call which would
update the saved status and the kernel status will be overwritten with
the old (incorrect) value in a later TMX_*() call.

Always call TMX_SetLeap() to save the new value and for the log message
selection just check if a leap second has been applied.

sys_linux.c
wrap_adjtimex.c
wrap_adjtimex.h

index d1849ca9c4a68cebb6809881397929ce148ae6e8..c315015623cad95ea0498b9536f02cbdb1198b84 100644 (file)
@@ -173,15 +173,13 @@ read_frequency(void)
 static void
 set_leap(int leap)
 {
-  int current_leap, applied;
+  int applied;
 
-  if (TMX_GetLeap(&current_leap, &applied) < 0) {
+  applied = 0;
+  if (!leap && TMX_GetLeapApplied(&applied) < 0) {
     LOG_FATAL(LOGF_SysLinux, "adjtimex() failed in set_leap");
   }
 
-  if (current_leap == leap)
-    return;
-
   if (TMX_SetLeap(leap) < 0) {
     LOG_FATAL(LOGF_SysLinux, "adjtimex() failed in set_leap");
   }
index ce6f2679259afa9c83501c30765ba02616da8105..b5437185c69a56aeb3a2ca9fc31222db7e4350c1 100644 (file)
@@ -124,7 +124,7 @@ TMX_SetLeap(int leap)
 }
 
 int
-TMX_GetLeap(int *leap, int *applied)
+TMX_GetLeapApplied(int *applied)
 {
   struct timex txc;
   int state;
@@ -134,13 +134,6 @@ TMX_GetLeap(int *leap, int *applied)
   if (state < 0)
     return -1;
 
-  if (txc.status & STA_INS)
-    *leap = 1;
-  else if (txc.status & STA_DEL)
-    *leap = -1;
-  else
-    *leap = 0;
-
   *applied = state == TIME_WAIT;
 
   return 0;
index 217d06088f46eab0dea4697bdcae2489b55d792d..97d4164a5a0696d095a1cf0b5845906eec888807 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 *applied);
+int TMX_GetLeapApplied(int *applied);
 int TMX_SetSync(int sync, double est_error, double max_error);
 int TMX_TestStepOffset(void);
 int TMX_ApplyStepOffset(double offset);