mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 09:49:18 +02:00
Fix s2s_dns_timeout issues
This commit is contained in:
parent
a664d6389e
commit
9426c67302
2 changed files with 14 additions and 3 deletions
|
@ -404,7 +404,7 @@ transform_options({s2s_dns_options, S2SDNSOpts}, AllOpts) ->
|
||||||
transform_options({Opt, T}, Opts)
|
transform_options({Opt, T}, Opts)
|
||||||
when Opt == outgoing_s2s_timeout; Opt == s2s_dns_timeout ->
|
when Opt == outgoing_s2s_timeout; Opt == s2s_dns_timeout ->
|
||||||
maybe_report_huge_timeout(Opt, T),
|
maybe_report_huge_timeout(Opt, T),
|
||||||
[{outgoing_s2s_timeout, T}|Opts];
|
[{Opt, T}|Opts];
|
||||||
transform_options(Opt, Opts) ->
|
transform_options(Opt, Opts) ->
|
||||||
[Opt|Opts].
|
[Opt|Opts].
|
||||||
|
|
||||||
|
|
|
@ -886,9 +886,20 @@ a_lookup([], _State, Err) ->
|
||||||
a_lookup(_Host, _Port, _Family, _Timeout, Retries) when Retries < 1 ->
|
a_lookup(_Host, _Port, _Family, _Timeout, Retries) when Retries < 1 ->
|
||||||
{error, timeout};
|
{error, timeout};
|
||||||
a_lookup(Host, Port, Family, Timeout, Retries) ->
|
a_lookup(Host, Port, Family, Timeout, Retries) ->
|
||||||
|
Start = p1_time_compat:monotonic_time(milli_seconds),
|
||||||
case inet:gethostbyname(Host, Family, Timeout) of
|
case inet:gethostbyname(Host, Family, Timeout) of
|
||||||
{error, timeout} ->
|
{error, nxdomain} = Err ->
|
||||||
a_lookup(Host, Port, Family, Timeout, Retries - 1);
|
%% inet:gethostbyname/3 doesn't return {error, timeout},
|
||||||
|
%% so we should check if 'nxdomain' is in fact a result
|
||||||
|
%% of a timeout.
|
||||||
|
%% We also cannot use inet_res:gethostbyname/3 because
|
||||||
|
%% it ignores DNS configuration settings (/etc/hosts, etc)
|
||||||
|
End = p1_time_compat:monotonic_time(milli_seconds),
|
||||||
|
if (End - Start) >= Timeout ->
|
||||||
|
a_lookup(Host, Port, Family, Timeout, Retries - 1);
|
||||||
|
true ->
|
||||||
|
Err
|
||||||
|
end;
|
||||||
{error, _} = Err ->
|
{error, _} = Err ->
|
||||||
Err;
|
Err;
|
||||||
{ok, HostEntry} ->
|
{ok, HostEntry} ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue