Add support for timeout: and attempts: resolver options.

Submitted by:	Paul Vixie <paul@vix.com> / ISC
MFC After:	1 week
This commit is contained in:
Murray Stokely 2003-12-07 12:32:24 +00:00
parent 7c1da7529a
commit a298e0ba03
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=123236
3 changed files with 37 additions and 1 deletions

View File

@ -94,6 +94,8 @@
#define RES_TIMEOUT 5 /* min. seconds between retries */ #define RES_TIMEOUT 5 /* min. seconds between retries */
#define MAXRESOLVSORT 10 /* number of net to sort on */ #define MAXRESOLVSORT 10 /* number of net to sort on */
#define RES_MAXNDOTS 15 /* should reflect bit field size */ #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 { struct __res_state {
int retrans; /* retransmition time interval */ int retrans; /* retransmition time interval */

View File

@ -523,6 +523,26 @@ res_setoptions(options, source)
#ifdef DEBUG #ifdef DEBUG
if (_res.options & RES_DEBUG) if (_res.options & RES_DEBUG)
printf(";;\tndots=%d\n", _res.ndots); 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 #endif
} else if (!strncmp(cp, "debug", sizeof("debug") - 1)) { } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
#ifdef DEBUG #ifdef DEBUG

View File

@ -130,7 +130,7 @@ is one of the following:
sets sets
.Dv RES_DEBUG .Dv RES_DEBUG
in _res.options. 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 sets a threshold for the number of dots which must appear in a name given to
.Fn res_query .Fn res_query
(see (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 will be tried first as an absolute name before any
.Em search list .Em search list
elements are appended to it. 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 <resolv.h> ) .
.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 <resolv.h> ) .
.It Sy no_tld_query .It Sy no_tld_query
tells the resolver not to attempt to resolve a top level domain name, that 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 is, a name that contains no dots. Use of this option doesn't prevent