]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Don't lose remaining adjtime in initiate_slew
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 26 Aug 2009 15:58:57 +0000 (17:58 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 26 Aug 2009 15:58:57 +0000 (17:58 +0200)
initiate_slew is called also from set_frequency which doesn't read
the remaining adjtime. This wasn't a problem before commit 8c0f3f4
as offset_register was 0.0 and initiate_slew immediately returned.

sys_linux.c

index c60a7d3c433d6daba8207b51928c11a37f1cbddb..9a4e809b2c090a31e0e471cbf927c33b4587b477 100644 (file)
@@ -264,6 +264,13 @@ initiate_slew(void)
     return;
   }
 
+  /* Cancel any standard adjtime that is running */
+  offset = 0;
+  if (TMX_ApplyOffset(&offset) < 0) {
+    CROAK("adjtimex() failed in accrue_offset");
+  }
+  offset_register -= (double) offset / 1.0e6;
+
   if (fabs(offset_register) < MAX_ADJUST_WITH_ADJTIME) {
     /* Use adjtime to do the shift */
     offset = our_lround(1.0e6 * -offset_register);
@@ -383,19 +390,9 @@ abort_slew(void)
 static void
 accrue_offset(double offset)
 {
-  long toffset;
-  
   /* Add the new offset to the register */
   offset_register += offset;
 
-  /* Cancel any standard adjtime that is running */
-  toffset = 0;
-  if (TMX_ApplyOffset(&toffset) < 0) {
-    CROAK("adjtimex() failed in accrue_offset");
-  }
-
-  offset_register -= (double) toffset / 1.0e6;
-
   if (!fast_slewing) {
     initiate_slew();
   } /* Otherwise, when the fast slew completes, any other stuff