diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-02-20 10:42:16 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-02-20 10:42:16 +0300 |
commit | 9426c673024fd0344c3c1f89754dbe8d90c8b452 (patch) | |
tree | c5315e5bec98958216d0c78672cb5c08aef7f835 /src/xmpp_stream_out.erl | |
parent | Merge pull request #1555 from weiss/count-session-iq (diff) |
Fix s2s_dns_timeout issues
Diffstat (limited to 'src/xmpp_stream_out.erl')
-rw-r--r-- | src/xmpp_stream_out.erl | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/xmpp_stream_out.erl b/src/xmpp_stream_out.erl index 0843780f..5efc940c 100644 --- a/src/xmpp_stream_out.erl +++ b/src/xmpp_stream_out.erl @@ -886,9 +886,20 @@ a_lookup([], _State, Err) -> a_lookup(_Host, _Port, _Family, _Timeout, Retries) when Retries < 1 -> {error, timeout}; a_lookup(Host, Port, Family, Timeout, Retries) -> + Start = p1_time_compat:monotonic_time(milli_seconds), case inet:gethostbyname(Host, Family, Timeout) of - {error, timeout} -> - a_lookup(Host, Port, Family, Timeout, Retries - 1); + {error, nxdomain} = Err -> + %% 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 -> Err; {ok, HostEntry} -> |