From 8c79773d1d499ba53141c3785180e01b254a1e53 Mon Sep 17 00:00:00 2001 From: otto <> Date: Tue, 1 May 2007 07:40:45 +0000 Subject: [PATCH] if resolving a name fails, be more aggressive retrying, but with care: do not have more than one dns request outstanding per peer. resolves slow recovery when resolving fails initially, without clogging the pipe with lots of dns requests; tested by Jason George; ok deraadt@ --- src/usr.sbin/ntpd/client.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/usr.sbin/ntpd/client.c b/src/usr.sbin/ntpd/client.c index 4b404422..9cc558eb 100644 --- a/src/usr.sbin/ntpd/client.c +++ b/src/usr.sbin/ntpd/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.75 2007/04/30 01:33:33 deraadt Exp $ */ +/* $OpenBSD: client.c,v 1.76 2007/05/01 07:40:45 otto Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -99,6 +99,9 @@ client_nextaddr(struct ntp_peer *p) p->query->fd = -1; } + if (p->state == STATE_DNS_INPROGRESS) + return (-1); + if (p->addr_head.a == NULL) { priv_host_dns(p->addr_head.name, p->id); p->state = STATE_DNS_INPROGRESS; @@ -120,7 +123,7 @@ client_query(struct ntp_peer *p) int tos = IPTOS_LOWDELAY; if (p->addr == NULL && client_nextaddr(p) == -1) { - set_next(p, error_interval()); + set_next(p, scale_interval(INTERVAL_QUERY_AGGRESSIVE)); return (0); } @@ -137,7 +140,8 @@ client_query(struct ntp_peer *p) if (errno == ECONNREFUSED || errno == ENETUNREACH || errno == EHOSTUNREACH || errno == EADDRNOTAVAIL) { client_nextaddr(p); - set_next(p, error_interval()); + set_next(p, + scale_interval(INTERVAL_QUERY_AGGRESSIVE)); return (-1); } else fatal("client_query connect");