summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhenning <henning@openbsd.org>2005-03-08 16:33:43 +0000
committerhenning <henning@openbsd.org>2005-03-08 16:33:43 +0000
commit0f8bb54d49dbd89da094d4f876aaf604679a0c04 (patch)
tree7285e606662e8efaff5ab56d5f58c391b1990b3d
parentknf (diff)
downloadwireguard-openbsd-0f8bb54d49dbd89da094d4f876aaf604679a0c04.tar.xz
wireguard-openbsd-0f8bb54d49dbd89da094d4f876aaf604679a0c04.zip
when trying short-circuit the wait for the first reply for -s, only
do so when -we tried to send at least one query (that is the change) -we could not send ou a single one without failure (this was already in place but catched too much) problem independently noticed by nick and danh, ok mickey danh, testing by many
-rw-r--r--usr.sbin/ntpd/ntp.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 5b2635b1687..afd8e24e001 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.53 2005/03/08 16:27:14 deraadt Exp $ */
+/* $OpenBSD: ntp.c,v 1.54 2005/03/08 16:33:43 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -64,7 +64,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
{
int a, b, nfds, i, j, idx_peers, timeout, nullfd;
u_int pfd_elms = 0, idx2peer_elms = 0;
- u_int listener_cnt, new_cnt, sent_cnt;
+ u_int listener_cnt, new_cnt, sent_cnt, trial_cnt;
pid_t pid;
struct pollfd *pfd = NULL;
struct passwd *pw;
@@ -193,13 +193,15 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
}
idx_peers = i;
- sent_cnt = 0;
+ sent_cnt = trial_cnt = 0;
TAILQ_FOREACH(p, &conf->ntp_peers, entry) {
if (p->next > 0 && p->next < nextaction)
nextaction = p->next;
- if (p->next > 0 && p->next <= time(NULL))
+ if (p->next > 0 && p->next <= time(NULL)) {
+ trial_cnt++;
if (client_query(p) == 0)
sent_cnt++;
+ }
if (p->deadline > 0 && p->deadline < nextaction)
nextaction = p->deadline;
@@ -225,7 +227,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
}
}
- if (sent_cnt == 0 && conf->settime)
+ if (trial_cnt > 0 && sent_cnt == 0 && conf->settime)
priv_settime(0); /* no good peers, don't wait */
if (ibuf_main->w.queued > 0)