reference: improve check for close leap second

Improve the check to work with the actual timestamp of the leap second
instead of the closest midnight and don't turn it off on the leap
timeout. Also allow sample times to be checked in addition to the system
time and NTP time to avoid accumulation of samples mixing pre-leap and
post-leap timestamps (causing error of +/-0.5 or +/-1.0 seconds).
This commit is contained in:
Miroslav Lichvar
2020-03-25 09:12:35 +01:00
parent a6f2a613f3
commit c687224a11
3 changed files with 24 additions and 16 deletions

View File

@@ -361,7 +361,7 @@ get_leap_status(void)
void
SRC_SetLeapStatus(SRC_Instance inst, NTP_Leap leap)
{
if (REF_IsLeapSecondClose())
if (REF_IsLeapSecondClose(NULL, 0.0))
return;
inst->leap = leap;
@@ -390,7 +390,7 @@ SRC_AccumulateSample(SRC_Instance inst, NTP_Sample *sample)
source_to_string(inst), UTI_TimespecToString(&sample->time), -sample->offset,
sample->root_delay, sample->root_dispersion, sample->stratum);
if (REF_IsLeapSecondClose()) {
if (REF_IsLeapSecondClose(&sample->time, sample->offset)) {
LOG(LOGS_INFO, "Dropping sample around leap second");
return;
}