]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Reset adjtime offset on start
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 5 Aug 2010 11:27:52 +0000 (13:27 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 5 Aug 2010 11:27:52 +0000 (13:27 +0200)
sys_linux.c

index 641745280b04c76de4f70b8f86b3b572dfdb9d51..5a7b51fa13414fb2ecc023316d5c6dee38901d40 100644 (file)
@@ -678,13 +678,10 @@ get_offset_correction(struct timeval *raw,
   if (!slow_slewing) {
     offset = 0;
   } else {
-again:
     switch (have_readonly_adjtime) {
       case 2:
         if (TMX_GetOffsetLeft(&offset) < 0) {
-          LOG(LOGS_INFO, LOGF_SysLinux, "adjtimex() doesn't support ADJ_OFFSET_SS_READ");
-          have_readonly_adjtime = 0;
-          goto again;
+          CROAK("adjtimex() failed in get_offset_correction");
         }
         break;
       case 0:
@@ -933,18 +930,18 @@ get_version_specific_details(void)
             have_readonly_adjtime = 0;
             break;
           }
+          if (patch < 33) {
+            /* Tickless kernels before 2.6.33 accumulated ticks only in
+               half-second intervals. */
+            tick_update_hz = 2;
+          }
           /* Let's be optimistic that these will be the same until proven
              otherwise :-) */
         case 7:
         case 8:
-          /* These don't need scaling */
+          /* These don't seem to need scaling */
           freq_scale = 1.0;
           have_readonly_adjtime = 2;
-          if (minor == 6 && patch < 33) {
-            /* Tickless kernels before 2.6.33 accumulated ticks only in
-               half-second intervals. */
-            tick_update_hz = 2;
-          }
           break;
         default:
           LOG_FATAL(LOGF_SysLinux, "Kernel version not supported yet, sorry.");
@@ -971,6 +968,8 @@ get_version_specific_details(void)
 void
 SYS_Linux_Initialise(void)
 {
+  long offset;
+
   offset_register = 0.0;
   fast_slewing = 0;
 
@@ -983,6 +982,16 @@ SYS_Linux_Initialise(void)
                             accrue_offset, apply_step_offset,
                             get_offset_correction, set_leap);
 
+  offset = 0;
+  if (TMX_ApplyOffset(&offset) < 0) {
+    CROAK("adjtimex() failed in initialise");
+  }
+
+  if (have_readonly_adjtime == 2 && (TMX_GetOffsetLeft(&offset) < 0 || offset)) {
+    LOG(LOGS_INFO, LOGF_SysLinux, "adjtimex() doesn't support ADJ_OFFSET_SS_READ");
+    have_readonly_adjtime = 0;
+  }
+
   TMX_SetSync(CNF_GetRTCSync());
 }