summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-08-10 12:45:28 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-08-10 12:45:28 +0000
commit96261ec83c33eda3d76013f85a960dc972461d0e (patch)
treef4f64221bf4871ccbbc4efaa28eabc0fbab3b0f9 /usr.sbin
parent59a04d58f048fb9192fb0bad8a959bb1d6498d04 (diff)
in the pool case ("servers somepool.somewhere"), we add new peers while
looping over the addresses returned by the dns lookup, as each address is one new peer. however, if the lookup fails with a temporary error, we will try to lookup later again. for that, we obviously need to insert one peer with the hostname in addr_head... change one for() loop into a do { } while() one
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ntpd/parse.y34
1 files changed, 21 insertions, 13 deletions
diff --git a/usr.sbin/ntpd/parse.y b/usr.sbin/ntpd/parse.y
index 00a51546f65..e73572f1660 100644
--- a/usr.sbin/ntpd/parse.y
+++ b/usr.sbin/ntpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.18 2004/08/10 12:41:15 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.19 2004/08/10 12:45:27 henning Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -158,18 +158,23 @@ conf_main : LISTEN ON address {
struct ntp_peer *p;
struct ntp_addr *h, *next;
- for (h = $2->a; h != NULL; h = next) {
- next = h->next;
- if (h->ss.ss_family != AF_INET &&
- h->ss.ss_family != AF_INET6) {
- yyerror("IPv4 or IPv6 address "
- "or hostname expected");
- free($2->name);
- free($2);
- YYERROR;
- }
+ h = $2->a;
+ do {
+ if (h != NULL) {
+ next = h->next;
+ if (h->ss.ss_family != AF_INET &&
+ h->ss.ss_family != AF_INET6) {
+ yyerror("IPv4 or IPv6 address "
+ "or hostname expected");
+ free($2->name);
+ free($2);
+ YYERROR;
+ }
+ h->next = NULL;
+ } else
+ next = NULL;
+
p = new_peer();
- h->next = NULL;
p->addr = h;
p->addr_head.a = h;
p->addr_head.pool = 1;
@@ -177,7 +182,10 @@ conf_main : LISTEN ON address {
if (p->addr_head.name == NULL)
fatal(NULL);
TAILQ_INSERT_TAIL(&conf->ntp_peers, p, entry);
- }
+
+ h = next;
+ } while (h != NULL);
+
free($2->name);
free($2);
}