mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 06:55:06 -05:00
Ignore measurements around leap second
When current time is within 5 seconds of a leap second, don't accumulate new samples or update the leap second status to increase the chances of getting through safely.
This commit is contained in:
27
reference.c
27
reference.c
@@ -680,7 +680,7 @@ update_leap_status(NTP_Leap leap, time_t now)
|
||||
}
|
||||
}
|
||||
|
||||
if (leap_sec != our_leap_sec) {
|
||||
if (leap_sec != our_leap_sec && !REF_IsLeapSecondClose()) {
|
||||
LCL_SetLeap(leap_sec);
|
||||
our_leap_sec = leap_sec;
|
||||
}
|
||||
@@ -1150,6 +1150,31 @@ REF_IsLocalActive(void)
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
#define LEAP_SECOND_CLOSE 5
|
||||
|
||||
int REF_IsLeapSecondClose(void)
|
||||
{
|
||||
struct timeval now, now_raw;
|
||||
time_t t;
|
||||
|
||||
if (!our_leap_sec)
|
||||
return 0;
|
||||
|
||||
SCH_GetLastEventTime(&now, NULL, &now_raw);
|
||||
|
||||
t = now.tv_sec > 0 ? now.tv_sec : -now.tv_sec;
|
||||
if ((t + LEAP_SECOND_CLOSE) % (24 * 3600) < 2 * LEAP_SECOND_CLOSE)
|
||||
return 1;
|
||||
|
||||
t = now_raw.tv_sec > 0 ? now_raw.tv_sec : -now_raw.tv_sec;
|
||||
if ((t + LEAP_SECOND_CLOSE) % (24 * 3600) < 2 * LEAP_SECOND_CLOSE)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
REF_GetTrackingReport(RPT_TrackingReport *rep)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user