mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 17:35:06 -05:00
ntp: use monotonic time for replacement interval
Avoid errors in the measured interval due to clock steps.
This commit is contained in:
@@ -1006,11 +1006,10 @@ resolve_source_replacement(SourceRecord *record, int refreshment)
|
|||||||
void
|
void
|
||||||
NSR_HandleBadSource(IPAddr *address)
|
NSR_HandleBadSource(IPAddr *address)
|
||||||
{
|
{
|
||||||
static struct timespec last_replacement;
|
static double last_replacement = -1e6;
|
||||||
struct timespec now;
|
|
||||||
SourceRecord *record;
|
SourceRecord *record;
|
||||||
IPAddr ip_addr;
|
IPAddr ip_addr;
|
||||||
double diff;
|
double now;
|
||||||
int slot;
|
int slot;
|
||||||
|
|
||||||
if (!find_slot(address, &slot))
|
if (!find_slot(address, &slot))
|
||||||
@@ -1025,9 +1024,9 @@ NSR_HandleBadSource(IPAddr *address)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Don't resolve names too frequently */
|
/* Don't resolve names too frequently */
|
||||||
SCH_GetLastEventTime(NULL, NULL, &now);
|
now = SCH_GetLastEventMonoTime();
|
||||||
diff = UTI_DiffTimespecsToDouble(&now, &last_replacement);
|
if (now - last_replacement <
|
||||||
if (fabs(diff) < RESOLVE_INTERVAL_UNIT * (1 << MIN_REPLACEMENT_INTERVAL)) {
|
RESOLVE_INTERVAL_UNIT * (1 << MIN_REPLACEMENT_INTERVAL)) {
|
||||||
DEBUG_LOG("replacement postponed");
|
DEBUG_LOG("replacement postponed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user