summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhenning <henning@openbsd.org>2005-02-22 12:03:24 +0000
committerhenning <henning@openbsd.org>2005-02-22 12:03:24 +0000
commit6d7ece660a2e7f3d5911f95ee00ea37eb90ccf39 (patch)
tree73e21cd8228b52e529c5cceea20c6fa4815c9246
parentget timezone right before chroot() by calling tzset() (diff)
downloadwireguard-openbsd-6d7ece660a2e7f3d5911f95ee00ea37eb90ccf39.tar.xz
wireguard-openbsd-6d7ece660a2e7f3d5911f95ee00ea37eb90ccf39.zip
when sending a query already returns a failure, we're not going to see
a reply to that query. if we get errors for all queries and the initial settime() is still due and thus the parent process still waits (not yet daemonized!), send an IMSG_SETTIME with offset 0. shortens the delay dramatically when you boot without network idea from a discussion with theo
-rw-r--r--usr.sbin/ntpd/ntp.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index d25d370b1e4..9c743ef3bab 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.50 2005/02/02 19:03:52 henning Exp $ */
+/* $OpenBSD: ntp.c,v 1.51 2005/02/22 12:03:24 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;
+ u_int listener_cnt, new_cnt, sent_cnt;
pid_t pid;
struct pollfd *pfd = NULL;
struct passwd *pw;
@@ -191,11 +191,13 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
}
idx_peers = i;
+ sent_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))
- client_query(p);
+ if (client_query(p) == 0)
+ sent_cnt++;
if (p->deadline > 0 && p->deadline < nextaction)
nextaction = p->deadline;
@@ -221,6 +223,9 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
}
}
+ if (sent_cnt == 0 && conf->settime)
+ priv_settime(0); /* no good peers, don't wait */
+
if (ibuf_main->w.queued > 0)
pfd[PFD_PIPE_MAIN].events |= POLLOUT;