summaryrefslogtreecommitdiff
path: root/src/timedate/timedate-sntp.c
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2014-04-10 12:58:10 -0700
committerKay Sievers <kay@vrfy.org>2014-04-10 12:58:10 -0700
commitd8c21348dfe8abd6557366f7982886248544e87a (patch)
tree7fb4f544038f4262a15187b069ccc710ed52882e /src/timedate/timedate-sntp.c
parent1b89cf56483991c1b6eaa2dcd375630f4623ba3a (diff)
timedated: ignore initial delta in history data
Diffstat (limited to 'src/timedate/timedate-sntp.c')
-rw-r--r--src/timedate/timedate-sntp.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/timedate/timedate-sntp.c b/src/timedate/timedate-sntp.c
index b5d60c60af..a85b377752 100644
--- a/src/timedate/timedate-sntp.c
+++ b/src/timedate/timedate-sntp.c
@@ -399,6 +399,12 @@ static bool sntp_sample_spike_detection(SNTPContext *sntp, double offset, double
double jitter;
double j;
+ sntp->packet_count++;
+
+ /* ignore initial sample */
+ if (sntp->packet_count == 1)
+ return false;
+
/* store the current data in our samples array */
idx_cur = sntp->samples_idx;
idx_new = (idx_cur + 1) % ELEMENTSOF(sntp->samples);
@@ -406,10 +412,8 @@ static bool sntp_sample_spike_detection(SNTPContext *sntp, double offset, double
sntp->samples[idx_new].offset = offset;
sntp->samples[idx_new].delay = delay;
- sntp->packet_count++;
- jitter = sntp->samples_jitter;
-
/* calculate new jitter value from the RMS differences relative to the lowest delay sample */
+ jitter = sntp->samples_jitter;
for (idx_min = idx_cur, i = 0; i < ELEMENTSOF(sntp->samples); i++)
if (sntp->samples[i].delay > 0 && sntp->samples[i].delay < sntp->samples[idx_min].delay)
idx_min = i;