]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Handle immediate step in local module instead of system driver
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 25 Jan 2010 12:07:13 +0000 (13:07 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 25 Jan 2010 14:51:15 +0000 (15:51 +0100)
This fixes the problem where scheduler wasn't notified about performed
steps and it also makes the command available on all supported systems.

chrony.texi
local.c
localp.h
sys_linux.c
sys_netbsd.c
sys_solaris.c
sys_sunos.c

index 9fc672f4ee1ed963a064f8de37a3de327bc570e9..f3d0c85bff1f060d3fe1658d949443796f2d0941 100644 (file)
@@ -3075,9 +3075,6 @@ clock by the equivalent amount, making it correct immediately.
 BE WARNED - certain software will be seriously affected by such jumps to
 the system time.  (That is the reason why chronyd uses slewing
 normally.)
-
-The @code{makestep} command is currently only available on the Linux
-version of chrony.
 @c }}}
 @c {{{ manual
 @node manual command
diff --git a/local.c b/local.c
index c1542bd41ecb535e226a06794c9aa5ed108503a3..a1e95f568bcd5eb888b1d8ca146235144945a43c 100644 (file)
--- a/local.c
+++ b/local.c
@@ -53,7 +53,6 @@ static lcl_SetFrequencyDriver drv_set_freq;
 static lcl_AccrueOffsetDriver drv_accrue_offset;
 static lcl_ApplyStepOffsetDriver drv_apply_step_offset;
 static lcl_OffsetCorrectionDriver drv_offset_convert;
-static lcl_ImmediateStepDriver drv_immediate_step;
 static lcl_SetLeapDriver drv_set_leap;
 
 /* ================================================== */
@@ -536,7 +535,6 @@ lcl_RegisterSystemDrivers(lcl_ReadFrequencyDriver read_freq,
                           lcl_AccrueOffsetDriver accrue_offset,
                           lcl_ApplyStepOffsetDriver apply_step_offset,
                           lcl_OffsetCorrectionDriver offset_convert,
-                          lcl_ImmediateStepDriver immediate_step,
                           lcl_SetLeapDriver set_leap)
 {
   drv_read_freq = read_freq;
@@ -544,7 +542,6 @@ lcl_RegisterSystemDrivers(lcl_ReadFrequencyDriver read_freq,
   drv_accrue_offset = accrue_offset;
   drv_apply_step_offset = apply_step_offset;
   drv_offset_convert = offset_convert;
-  drv_immediate_step = immediate_step;
   drv_set_leap = set_leap;
 
   current_freq_ppm = (*drv_read_freq)();
@@ -563,15 +560,19 @@ lcl_RegisterSystemDrivers(lcl_ReadFrequencyDriver read_freq,
 int
 LCL_MakeStep(void)
 {
-  if (drv_immediate_step) {
-    (drv_immediate_step)();
-#ifdef TRACEON
-    LOG(LOGS_INFO, LOGF_Local, "Made step to system time to apply remaining slew");
-#endif
-    return 1;
-  }
+  struct timeval raw;
+  double correction;
+
+  LCL_ReadRawTime(&raw);
+  correction = LCL_GetOffsetCorrection(&raw);
+
+  /* Cancel remaining slew and make the step */
+  LCL_AccumulateOffset(correction);
+  LCL_ApplyStepOffset(-correction);
+
+  LOG(LOGS_WARN, LOGF_Local, "System clock was stepped by %.3f seconds", correction);
 
-  return 0;
+  return 1;
 }
 
 /* ================================================== */
index 045c903b46fee19f28e9076f0a94c4a8b1fb2667..47d7eb12434907b74dd4bc21540bb543a5fd1fec 100644 (file)
--- a/localp.h
+++ b/localp.h
@@ -56,10 +56,6 @@ typedef void (*lcl_ApplyStepOffsetDriver)(double offset);
    raw time to get the corrected time */
 typedef void (*lcl_OffsetCorrectionDriver)(struct timeval *raw, double *corr);
 
-/* System driver to stop slewing the current offset and to apply is
-   as an immediate step instead */
-typedef void (*lcl_ImmediateStepDriver)(void);
-
 /* System driver to schedule leap second */
 typedef void (*lcl_SetLeapDriver)(int leap);
 
@@ -71,7 +67,6 @@ lcl_RegisterSystemDrivers(lcl_ReadFrequencyDriver read_freq,
                           lcl_AccrueOffsetDriver accrue_offset,
                           lcl_ApplyStepOffsetDriver apply_step_offset,
                           lcl_OffsetCorrectionDriver offset_convert,
-                          lcl_ImmediateStepDriver immediate_step_driver,
                           lcl_SetLeapDriver set_leap);
 
 #endif /* GOT_LOCALP_H */
index 67ec418a8c136d990dcec6346617c216efaa6982..f46b05567d06c2f3e71e7f599170d6bab211d148 100644 (file)
@@ -608,42 +608,6 @@ again:
 
 /* ================================================== */
 
-static void
-immediate_step(void)
-{
-  struct timeval old_time, new_time;
-  struct timezone tz;
-  long offset;
-
-  if (fast_slewing) {
-    abort_slew();
-  }
-
-  offset = 0;
-  if (TMX_ApplyOffset(&offset) < 0) {
-    CROAK("adjtimex() failed in immediate_step");
-  }
-
-  offset_register -= (double) offset / 1.0e6;
-  slow_slewing = 0;
-
-  if (gettimeofday(&old_time, &tz) < 0) {
-    CROAK("gettimeofday() failed in immediate_step");
-  }
-
-  UTI_AddDoubleToTimeval(&old_time, -offset_register, &new_time);
-
-  if (settimeofday(&new_time, &tz) < 0) {
-    CROAK("settimeofday() failed in immediate_step");
-  }
-
-  offset_register = 0.0;
-
-  return;
-}
-
-/* ================================================== */
-
 static void
 set_leap(int leap)
 {
@@ -886,7 +850,7 @@ SYS_Linux_Initialise(void)
 
   lcl_RegisterSystemDrivers(read_frequency, set_frequency,
                             accrue_offset, apply_step_offset,
-                            get_offset_correction, immediate_step, set_leap);
+                            get_offset_correction, set_leap);
 }
 
 /* ================================================== */
index 01cab829fbec8bab7f89766745e04c6865cd573d..4641ee4f25eafb57335af561cc0f65a19ddc4af9 100644 (file)
@@ -309,7 +309,7 @@ SYS_NetBSD_Initialise(void)
 
   lcl_RegisterSystemDrivers(read_frequency, set_frequency, 
                             accrue_offset, apply_step_offset,
-                            get_offset_correction, NULL /* immediate_step */,
+                            get_offset_correction,
                             NULL /* set_leap */);
 
 }
index a1d2264365f7a25e09015d0734c20bbeedd1b3a8..6c6570582c71ad4120ae461bb8b38c19d0943796 100644 (file)
@@ -444,7 +444,7 @@ SYS_Solaris_Initialise(void)
 
   lcl_RegisterSystemDrivers(read_frequency, set_frequency, 
                             accrue_offset, apply_step_offset,
-                            get_offset_correction, NULL /* immediate_step */,
+                            get_offset_correction,
                             NULL /* set_leap */);
 
   /* Turn off the kernel switch that keeps the system clock in step
index 2224e0b3259834fb5f2203be523074c569e46e91..13bb262144d5efe78ef2d392498bc2873b13049d 100644 (file)
@@ -395,7 +395,7 @@ SYS_SunOS_Initialise(void)
 
   lcl_RegisterSystemDrivers(read_frequency, set_frequency, 
                             accrue_offset, apply_step_offset,
-                            get_offset_correction, NULL /* immediate_step */,
+                            get_offset_correction,
                             NULL /* set_leap */);
 
   /* Turn off the kernel switch that keeps the system clock in step