Handle immediate step in local module instead of system driver
This fixes the problem where scheduler wasn't notified about performed steps and it also makes the command available on all supported systems.
This commit is contained in:
parent
52d0c9a057
commit
15e154c09d
7 changed files with 16 additions and 59 deletions
|
@ -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
|
||||
|
|
23
local.c
23
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;
|
||||
|
||||
return 0;
|
||||
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 1;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
|
5
localp.h
5
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 */
|
||||
|
|
38
sys_linux.c
38
sys_linux.c
|
@ -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);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
|
|
@ -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 */);
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue