Browse Source

check wether we have enough data to form a peer update on receiption

of each packet, not only after each 8th (where we have enough for sure)
OPENBSD_3_6
henning 20 years ago
parent
commit
042700aed2
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      src/usr.sbin/ntpd/client.c

+ 5
- 5
src/usr.sbin/ntpd/client.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: client.c,v 1.21 2004/07/10 18:47:49 henning Exp $ */
/* $OpenBSD: client.c,v 1.22 2004/07/10 19:09:13 henning Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -202,14 +202,14 @@ client_dispatch(struct ntp_peer *p)
p->trustlevel++; p->trustlevel++;
} }
client_update(p);
log_debug("reply from %s: offset %f delay %f, " log_debug("reply from %s: offset %f delay %f, "
"next query %ds", log_sockaddr((struct sockaddr *)&fsa), "next query %ds", log_sockaddr((struct sockaddr *)&fsa),
p->reply[p->shift].offset, p->reply[p->shift].delay, interval); p->reply[p->shift].offset, p->reply[p->shift].delay, interval);
if (++p->shift >= OFFSET_ARRAY_SIZE) {
if (++p->shift >= OFFSET_ARRAY_SIZE)
p->shift = 0; p->shift = 0;
client_update(p);
}
return (0); return (0);
} }
@ -243,7 +243,7 @@ client_update(struct ntp_peer *p)
best = i; best = i;
} }
if (good == 0)
if (good < 8)
return (-1); return (-1);
memcpy(&p->update, &p->reply[best], sizeof(p->update)); memcpy(&p->update, &p->reply[best], sizeof(p->update));


Loading…
Cancel
Save