diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-07-05 22:12:54 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-07-05 22:12:54 +0000 |
commit | 3de5171cc6d6cdb3c739120dc65c9e647c79d1b1 (patch) | |
tree | 79e2916e7df3406a45e365b7005ff3ce4026adcf /usr.sbin/ntpd/client.c | |
parent | c8fc69a63dbfc17fd6b74d184c14f3d77732b2b3 (diff) |
keep last 8 offset,delay pairs - we'll need them for the clock filters later.
for now, average over those to adjust the local clock.
Diffstat (limited to 'usr.sbin/ntpd/client.c')
-rw-r--r-- | usr.sbin/ntpd/client.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c index 8b97f9f82ee..2e300e1656a 100644 --- a/usr.sbin/ntpd/client.c +++ b/usr.sbin/ntpd/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.6 2004/07/05 20:41:34 henning Exp $ */ +/* $OpenBSD: client.c,v 1.7 2004/07/05 22:12:53 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -135,14 +135,20 @@ client_dispatch(struct ntp_peer *p) T2 = lfp_to_d(msg.rectime); T3 = lfp_to_d(msg.xmttime); - p->offset = ((T2 - T1) + (T3 - T4)) / 2; - p->delay = (T2 - T1) - (T3 - T4); + p->offset[p->shift] = ((T2 - T1) + (T3 - T4)) / 2; + p->delay[p->shift] = (T2 - T1) - (T3 - T4); p->state = STATE_REPLY_RECEIVED; p->next = time(NULL) + INTERVAL_QUERY; p->deadline = 0; - log_debug("reply received: offset %f delay %f", p->offset, p->delay); + log_debug("reply received: offset %f delay %f", p->offset[p->shift], + p->delay[p->shift]); + + if (++p->shift >= OFFSET_ARRAY_SIZE) { + p->shift = 0; + p->valid = 1; + } return (0); } |