mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-05 14:05:07 -05:00
refclock: fix check for old samples
The fix in commit 0a848e2528 was
incorrect.
This commit is contained in:
16
refclock.c
16
refclock.c
@@ -92,7 +92,7 @@ static ARR_Instance refclocks;
|
|||||||
|
|
||||||
static LOG_FileID logfileid;
|
static LOG_FileID logfileid;
|
||||||
|
|
||||||
static int valid_sample_time(RCL_Instance instance, struct timeval *tv);
|
static int valid_sample_time(RCL_Instance instance, struct timeval *raw, struct timeval *cooked);
|
||||||
static int pps_stratum(RCL_Instance instance, struct timeval *tv);
|
static int pps_stratum(RCL_Instance instance, struct timeval *tv);
|
||||||
static void poll_timeout(void *arg);
|
static void poll_timeout(void *arg);
|
||||||
static void slew_samples(struct timeval *raw, struct timeval *cooked, double dfreq,
|
static void slew_samples(struct timeval *raw, struct timeval *cooked, double dfreq,
|
||||||
@@ -372,7 +372,7 @@ RCL_AddSample(RCL_Instance instance, struct timeval *sample_time, double offset,
|
|||||||
|
|
||||||
/* Make sure the timestamp and offset provided by the driver are sane */
|
/* Make sure the timestamp and offset provided by the driver are sane */
|
||||||
if (!UTI_IsTimeOffsetSane(sample_time, offset) ||
|
if (!UTI_IsTimeOffsetSane(sample_time, offset) ||
|
||||||
!valid_sample_time(instance, sample_time))
|
!valid_sample_time(instance, sample_time, &cooked_time))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (leap) {
|
switch (leap) {
|
||||||
@@ -412,7 +412,7 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
|
|||||||
dispersion += instance->precision;
|
dispersion += instance->precision;
|
||||||
|
|
||||||
if (!UTI_IsTimeOffsetSane(pulse_time, 0.0) ||
|
if (!UTI_IsTimeOffsetSane(pulse_time, 0.0) ||
|
||||||
!valid_sample_time(instance, pulse_time))
|
!valid_sample_time(instance, pulse_time, &cooked_time))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rate = instance->pps_rate;
|
rate = instance->pps_rate;
|
||||||
@@ -503,21 +503,21 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
valid_sample_time(RCL_Instance instance, struct timeval *tv)
|
valid_sample_time(RCL_Instance instance, struct timeval *raw, struct timeval *cooked)
|
||||||
{
|
{
|
||||||
struct timeval raw_time, last_sample_time;
|
struct timeval raw_time, last_sample_time;
|
||||||
double diff, last_offset, last_dispersion;
|
double diff, last_offset, last_dispersion;
|
||||||
|
|
||||||
LCL_ReadRawTime(&raw_time);
|
LCL_ReadRawTime(&raw_time);
|
||||||
UTI_DiffTimevalsToDouble(&diff, &raw_time, tv);
|
UTI_DiffTimevalsToDouble(&diff, &raw_time, raw);
|
||||||
|
|
||||||
if (diff < 0.0 || diff > UTI_Log2ToDouble(instance->poll + 1) ||
|
if (diff < 0.0 || diff > UTI_Log2ToDouble(instance->poll + 1) ||
|
||||||
(filter_get_last_sample(&instance->filter, &last_sample_time,
|
(filter_get_last_sample(&instance->filter, &last_sample_time,
|
||||||
&last_offset, &last_dispersion) &&
|
&last_offset, &last_dispersion) &&
|
||||||
UTI_CompareTimevals(&last_sample_time, tv) >= 0)) {
|
UTI_CompareTimevals(&last_sample_time, cooked) >= 0)) {
|
||||||
DEBUG_LOG(LOGF_Refclock, "%s refclock sample not valid age=%.6f ts=%s lastts=%s",
|
DEBUG_LOG(LOGF_Refclock, "%s refclock sample not valid age=%.6f raw=%s cooked=%s",
|
||||||
UTI_RefidToString(instance->ref_id), diff,
|
UTI_RefidToString(instance->ref_id), diff,
|
||||||
UTI_TimevalToString(tv), UTI_TimevalToString(&last_sample_time));
|
UTI_TimevalToString(raw), UTI_TimevalToString(cooked));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user