aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiroslav Lichvar <mlichvar@redhat.com>2014-10-05 03:10:15 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2014-10-05 03:11:53 +0200
commit760d035699c4a878f9109544c1d35ea0d5f6b76c (patch)
treee36b94993b03ea937b625e46047b871f62defd93
parentcd738711782d5860eeab4e7cefdd1f72dfb83810 (diff)
downloadbusybox-760d035699c4a878f9109544c1d35ea0d5f6b76c.tar.gz
ntpd: calculate offset to jitter ratio before updating jitter
The offset to jitter ratio is now calculated before updating jitter to make the test more sensitive. function old new delta ntp_init 460 474 +14 update_local_clock 752 764 +12 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 26/0) Total: 26 bytes Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/ntpd.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 838a367fe..2d4f076d9 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -1488,12 +1488,19 @@ update_local_clock(peer_t *p)
} else { /* abs_offset <= STEP_THRESHOLD */
+ /* The ratio is calculated before jitter is updated to make
+ * poll adjust code more sensitive to large offsets.
+ */
+ G.offset_to_jitter_ratio = abs_offset / G.discipline_jitter;
+
/* Compute the clock jitter as the RMS of exponentially
* weighted offset differences. Used by the poll adjust code.
*/
etemp = SQUARE(G.discipline_jitter);
dtemp = SQUARE(offset - G.last_update_offset);
G.discipline_jitter = SQRT(etemp + (dtemp - etemp) / AVG);
+ if (G.discipline_jitter < G_precision_sec)
+ G.discipline_jitter = G_precision_sec;
switch (G.discipline_state) {
case STATE_NSET:
@@ -1570,10 +1577,6 @@ update_local_clock(peer_t *p)
}
}
- if (G.discipline_jitter < G_precision_sec)
- G.discipline_jitter = G_precision_sec;
- G.offset_to_jitter_ratio = abs_offset / G.discipline_jitter;
-
G.reftime = G.cur_time;
G.ntp_status = p->lastpkt_status;
G.refid = p->lastpkt_refid;
@@ -2111,6 +2114,7 @@ static NOINLINE void ntp_init(char **argv)
bb_error_msg_and_die(bb_msg_you_must_be_root);
/* Set some globals */
+ G.discipline_jitter = G_precision_sec;
G.stratum = MAXSTRAT;
if (BURSTPOLL != 0)
G.poll_exp = BURSTPOLL; /* speeds up initial sync */