refclock: honour leap second flag in the PPS refclock
This patch fixes leap second handling for the PPS refclock. Without the patch the PPS refclock will always report LEAP_normal. But if a locked refclock (the SHM clock in my case) does report a leap state it should also be taken over by the PPS refclock, otherwise chrony will still use LEAP_normal when the PPS clock is used as reference source. The patch will copy the leap state from the refclock. In case the PPS clock is not specifically locked to another refclock it will take over the leap state from the local clock. I've tested this patch by simulating a leap second through the samples for the SHM clock, and with the patch you will see chrony properly jump forward or backward on the leap second. Without the patch it will not do this and the clock becomes desynchronized and no leap state is reported upstream to other NTP clients. Signed-off-by: Tjalling Hattink <t.hattink@fugro.nl>
This commit is contained in:
parent
f88a712d01
commit
8210be0f17
1 changed files with 5 additions and 2 deletions
|
@ -385,7 +385,9 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
|
||||||
double correction, dispersion, offset;
|
double correction, dispersion, offset;
|
||||||
struct timeval cooked_time;
|
struct timeval cooked_time;
|
||||||
int rate;
|
int rate;
|
||||||
|
NTP_Leap leap;
|
||||||
|
|
||||||
|
leap = LEAP_Normal;
|
||||||
LCL_GetOffsetCorrection(pulse_time, &correction, &dispersion);
|
LCL_GetOffsetCorrection(pulse_time, &correction, &dispersion);
|
||||||
UTI_AddDoubleToTimeval(pulse_time, correction, &cooked_time);
|
UTI_AddDoubleToTimeval(pulse_time, correction, &cooked_time);
|
||||||
dispersion += instance->precision + filter_get_avg_sample_dispersion(&instance->filter);
|
dispersion += instance->precision + filter_get_avg_sample_dispersion(&instance->filter);
|
||||||
|
@ -436,13 +438,14 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leap = refclocks[instance->lock_ref].leap_status;
|
||||||
|
|
||||||
DEBUG_LOG(LOGF_Refclock, "refclock pulse second=%.9f offset=%.9f offdiff=%.9f samplediff=%.9f",
|
DEBUG_LOG(LOGF_Refclock, "refclock pulse second=%.9f offset=%.9f offdiff=%.9f samplediff=%.9f",
|
||||||
second, offset, ref_offset - offset, sample_diff);
|
second, offset, ref_offset - offset, sample_diff);
|
||||||
} else {
|
} else {
|
||||||
struct timeval ref_time;
|
struct timeval ref_time;
|
||||||
int is_synchronised, stratum;
|
int is_synchronised, stratum;
|
||||||
double root_delay, root_dispersion, distance;
|
double root_delay, root_dispersion, distance;
|
||||||
NTP_Leap leap;
|
|
||||||
uint32_t ref_id;
|
uint32_t ref_id;
|
||||||
|
|
||||||
/* Ignore the pulse if we are not well synchronized */
|
/* Ignore the pulse if we are not well synchronized */
|
||||||
|
@ -461,7 +464,7 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_add_sample(&instance->filter, &cooked_time, offset, dispersion);
|
filter_add_sample(&instance->filter, &cooked_time, offset, dispersion);
|
||||||
instance->leap_status = LEAP_Normal;
|
instance->leap_status = leap;
|
||||||
instance->pps_active = 1;
|
instance->pps_active = 1;
|
||||||
|
|
||||||
log_sample(instance, &cooked_time, 0, 1, offset + correction - instance->offset, offset, dispersion);
|
log_sample(instance, &cooked_time, 0, 1, offset + correction - instance->offset, offset, dispersion);
|
||||||
|
|
Loading…
Reference in a new issue