From a298e0ba0375b0febb03f76fd1102d04f32233b8 Mon Sep 17 00:00:00 2001 From: Murray Stokely Date: Sun, 7 Dec 2003 12:32:24 +0000 Subject: [PATCH] Add support for timeout: and attempts: resolver options. Submitted by: Paul Vixie / ISC MFC After: 1 week --- include/resolv.h | 2 ++ lib/libc/net/res_init.c | 20 ++++++++++++++++++++ share/man/man5/resolver.5 | 16 +++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/include/resolv.h b/include/resolv.h index 12d14b4fafd6..9305023dbb9a 100644 --- a/include/resolv.h +++ b/include/resolv.h @@ -94,6 +94,8 @@ #define RES_TIMEOUT 5 /* min. seconds between retries */ #define MAXRESOLVSORT 10 /* number of net to sort on */ #define RES_MAXNDOTS 15 /* should reflect bit field size */ +#define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */ +#define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */ struct __res_state { int retrans; /* retransmition time interval */ diff --git a/lib/libc/net/res_init.c b/lib/libc/net/res_init.c index 9bb845269c18..6c229730df77 100644 --- a/lib/libc/net/res_init.c +++ b/lib/libc/net/res_init.c @@ -523,6 +523,26 @@ res_setoptions(options, source) #ifdef DEBUG if (_res.options & RES_DEBUG) printf(";;\tndots=%d\n", _res.ndots); +#endif + } else if (!strncmp(cp, "timeout:", sizeof("timeout:") - 1)) { + i = atoi(cp + sizeof("timeout:") - 1); + if (i <= RES_MAXRETRANS) + _res.retrans = i; + else + _res.retrans = RES_MAXRETRANS; +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf(";;\ttimeout=%d\n", _res.retrans); +#endif + } else if (!strncmp(cp, "attempts:", sizeof("attempts:") - 1)){ + i = atoi(cp + sizeof("attempts:") - 1); + if (i <= RES_MAXRETRY) + _res.retry = i; + else + _res.retry = RES_MAXRETRY; +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf(";;\tretry=%d\n", _res.retry); #endif } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) { #ifdef DEBUG diff --git a/share/man/man5/resolver.5 b/share/man/man5/resolver.5 index 16320af39914..535b54e81c95 100644 --- a/share/man/man5/resolver.5 +++ b/share/man/man5/resolver.5 @@ -130,7 +130,7 @@ is one of the following: sets .Dv RES_DEBUG in _res.options. -.It Sy ndots:n +.It Sy ndots: Ns Ar n sets a threshold for the number of dots which must appear in a name given to .Fn res_query (see @@ -146,6 +146,20 @@ meaning that if there are any dots in a name, the name will be tried first as an absolute name before any .Em search list elements are appended to it. +.It Sy timeout: Ns Ar n +sets the amount of time the resolver will wait for a response from a remote +name server before retrying the query via a different name server. Measured in +seconds, the default is +.Dv RES_TIMEOUT +(see +.Pa ) . +.It Sy attempts: Ns Ar n +sets the number of times the resolver will send a query to its name servers +before giving up and returning an error to the calling application. The +default is +.Dv RES_DFLRETRY +(see +.Pa ) . .It Sy no_tld_query tells the resolver not to attempt to resolve a top level domain name, that is, a name that contains no dots. Use of this option doesn't prevent