diff options
author | Micael Karlberg <bmk@erlang.org> | 2020-10-26 14:58:02 +0100 |
---|---|---|
committer | Micael Karlberg <bmk@erlang.org> | 2020-10-26 14:58:02 +0100 |
commit | 4441e664e84c45030d67e27ab3f56bd35bcec541 (patch) | |
tree | 3fbda125926d7c8090f57db734d9fe380e135658 /lib/kernel/src/inet_res.erl | |
parent | 0e7de12e4b061e3e0f1268e0390bbf10c6778b04 (diff) | |
download | erlang-4441e664e84c45030d67e27ab3f56bd35bcec541.tar.gz |
[kernel] Add new option 'servfail_retry_timeout'
As of version NNN of the DNS server, there is a servfail cache
which has the servfail-ttl default value of 1 sec.
This means if the agent is "to eager" after a servfail, it will
just get the cache'd value (that is, no dns lookup is attempted).
To avoid the situation, a new config option has been added;
servfail_retry_timeout (with default 1500 = 1.5 sec), which
defines the timeout after each failed query, before attempting
a new query.
OTP-16956
Diffstat (limited to 'lib/kernel/src/inet_res.erl')
-rw-r--r-- | lib/kernel/src/inet_res.erl | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/kernel/src/inet_res.erl b/lib/kernel/src/inet_res.erl index 7886ef83ac..620dfd0052 100644 --- a/lib/kernel/src/inet_res.erl +++ b/lib/kernel/src/inet_res.erl @@ -259,7 +259,7 @@ do_nslookup(Name, Class, Type, Opts, Timeout) -> %% -record(options, { % These must be sorted! alt_nameservers,edns,inet6,nameservers,recurse, - retry,timeout,udp_payload_size,usevc, + retry,servfail_retry_timeout,timeout,udp_payload_size,usevc, verbose}). % this is a local option, not in inet_db %% %% Opts when is_list(Opts) -> #options{} @@ -772,8 +772,18 @@ query_retries(_Q, _NSs, _Timer, Retry, Retry, S, Reason) -> query_retries(_Q, [], _Timer, _Retry, _I, S, Reason) -> query_retries_error(S, Reason); query_retries(Q, NSs, Timer, Retry, I, S_0, Reason) -> + servfail_retry_wait(Q, I), query_nss(Q, NSs, Timer, Retry, I, S_0, Reason, NSs). +servfail_retry_wait(_Q, 0) -> + ok; +servfail_retry_wait(#q{options = #options{servfail_retry_timeout = T}}, _) + when (T > 0) -> + receive after T -> ok end; +servfail_retry_wait(_, _) -> + ok. + + %% Loop for all name servers, for each: %% If EDNS is enabled, try that first, %% and for selected failures fall back to plain DNS. |