Browse Source

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@
OPENBSD_4_2
otto 17 years ago
parent
commit
8c79773d1d
1 changed files with 7 additions and 3 deletions
  1. +7
    -3
      src/usr.sbin/ntpd/client.c

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

@ -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 <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -99,6 +99,9 @@ client_nextaddr(struct ntp_peer *p)
p->query->fd = -1; p->query->fd = -1;
} }
if (p->state == STATE_DNS_INPROGRESS)
return (-1);
if (p->addr_head.a == NULL) { if (p->addr_head.a == NULL) {
priv_host_dns(p->addr_head.name, p->id); priv_host_dns(p->addr_head.name, p->id);
p->state = STATE_DNS_INPROGRESS; p->state = STATE_DNS_INPROGRESS;
@ -120,7 +123,7 @@ client_query(struct ntp_peer *p)
int tos = IPTOS_LOWDELAY; int tos = IPTOS_LOWDELAY;
if (p->addr == NULL && client_nextaddr(p) == -1) { if (p->addr == NULL && client_nextaddr(p) == -1) {
set_next(p, error_interval());
set_next(p, scale_interval(INTERVAL_QUERY_AGGRESSIVE));
return (0); return (0);
} }
@ -137,7 +140,8 @@ client_query(struct ntp_peer *p)
if (errno == ECONNREFUSED || errno == ENETUNREACH || if (errno == ECONNREFUSED || errno == ENETUNREACH ||
errno == EHOSTUNREACH || errno == EADDRNOTAVAIL) { errno == EHOSTUNREACH || errno == EADDRNOTAVAIL) {
client_nextaddr(p); client_nextaddr(p);
set_next(p, error_interval());
set_next(p,
scale_interval(INTERVAL_QUERY_AGGRESSIVE));
return (-1); return (-1);
} else } else
fatal("client_query connect"); fatal("client_query connect");


Loading…
Cancel
Save