Fix fabs use on delay
This commit is contained in:
parent
52272f4dc5
commit
ff8e04f9ba
3 changed files with 9 additions and 9 deletions
12
ntp_core.c
12
ntp_core.c
|
@ -941,7 +941,7 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins
|
|||
skew = (source_freq_hi - source_freq_lo) / 2.0;
|
||||
|
||||
/* and then calculate peer dispersion */
|
||||
epsilon = LCL_GetSysPrecisionAsQuantum() + now_err + skew * local_interval;
|
||||
epsilon = LCL_GetSysPrecisionAsQuantum() + now_err + skew * fabs(local_interval);
|
||||
|
||||
} else {
|
||||
/* If test3 failed, we probably can't calculate these quantities
|
||||
|
@ -988,8 +988,8 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins
|
|||
the standard deviation of the offsets in the register is less than an
|
||||
administrator-defined value or the difference between measured offset
|
||||
and predicted offset is larger than the increase in delay */
|
||||
if (!SRC_IsGoodSample(inst->source, -theta, delta, inst->max_delay_dev_ratio,
|
||||
LCL_GetMaxClockError(), &sample_time)) {
|
||||
if (!SRC_IsGoodSample(inst->source, -theta, fabs(delta),
|
||||
inst->max_delay_dev_ratio, LCL_GetMaxClockError(), &sample_time)) {
|
||||
test4c = 0; /* Failed */
|
||||
} else {
|
||||
test4c = 1; /* Success */
|
||||
|
@ -1058,7 +1058,7 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins
|
|||
|
||||
/* Test 8 checks that the root delay and dispersion quoted in
|
||||
the packet are appropriate */
|
||||
if ((fabs(pkt_root_delay) >= NTP_MAX_DISPERSION) ||
|
||||
if ((pkt_root_delay >= NTP_MAX_DISPERSION) ||
|
||||
(pkt_root_dispersion >= NTP_MAX_DISPERSION)) {
|
||||
test8 = 0; /* Failed */
|
||||
} else {
|
||||
|
@ -1078,7 +1078,7 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins
|
|||
valid_header = test5 && test6 && test7i && test8;
|
||||
good_header = valid_header && test7ii;
|
||||
|
||||
root_delay = pkt_root_delay + delta;
|
||||
root_delay = pkt_root_delay + fabs(delta);
|
||||
root_dispersion = pkt_root_dispersion + epsilon;
|
||||
|
||||
#ifdef TRACEON
|
||||
|
@ -1158,7 +1158,7 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins
|
|||
|
||||
SRC_AccumulateSample(inst->source,
|
||||
&sample_time,
|
||||
theta, delta, epsilon,
|
||||
theta, fabs(delta), epsilon,
|
||||
root_delay, root_dispersion,
|
||||
message->stratum, (NTP_Leap) pkt_leap);
|
||||
|
||||
|
|
|
@ -547,7 +547,7 @@ SRC_SelectSource(uint32_t match_refid)
|
|||
&(si->variance),
|
||||
&(si->select_ok));
|
||||
|
||||
si->root_distance = si->root_dispersion + 0.5 * fabs(si->root_delay);
|
||||
si->root_distance = si->root_dispersion + 0.5 * si->root_delay;
|
||||
si->lo_limit = si->best_offset - si->root_distance;
|
||||
si->hi_limit = si->best_offset + si->root_distance;
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ SST_AccumulateSample(SST_Stats inst, struct timeval *sample_time,
|
|||
inst->sample_times[n] = *sample_time;
|
||||
inst->offsets[n] = offset;
|
||||
inst->orig_offsets[m] = offset;
|
||||
inst->peer_delays[m] = fabs(peer_delay);
|
||||
inst->peer_delays[m] = peer_delay;
|
||||
inst->peer_dispersions[m] = peer_dispersion;
|
||||
inst->root_delays[m] = root_delay;
|
||||
inst->root_dispersions[m] = root_dispersion;
|
||||
|
@ -334,7 +334,7 @@ find_best_sample_index(SST_Stats inst, double *times_back)
|
|||
elapsed = -times_back[i];
|
||||
assert(elapsed >= 0.0);
|
||||
|
||||
root_distance = inst->root_dispersions[j] + elapsed * inst->skew + 0.5 * fabs(inst->root_delays[j]);
|
||||
root_distance = inst->root_dispersions[j] + elapsed * inst->skew + 0.5 * inst->root_delays[j];
|
||||
if (root_distance < best_root_distance) {
|
||||
best_root_distance = root_distance;
|
||||
best_index = i;
|
||||
|
|
Loading…
Reference in a new issue