Skip to content

Commit

Permalink
Fixed dns lookup in case of server close connection with econnrefused
Browse files Browse the repository at this point in the history
  • Loading branch information
Kozlov Yakov committed Sep 1, 2017
1 parent 50525f3 commit 8cb694b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/kernel/src/inet_res.erl
Original file line number Diff line number Diff line change
Expand Up @@ -859,15 +859,17 @@ query_ns(S0, Id, Buffer, IP, Port, Timer, Retry, I,
{ok,S} ->
Timeout =
inet:timeout( (Tm * (1 bsl I)) div Retry, Timer),
{S,
case query_udp(
S, Id, Buffer, IP, Port, Timeout, Verbose) of
{ok,#dns_rec{header=H}} when H#dns_header.tc ->
TcpTimeout = inet:timeout(Tm*5, Timer),
query_tcp(
TcpTimeout, Id, Buffer, IP, Port, Verbose);
Reply -> Reply
end};
{S, query_tcp(
TcpTimeout, Id, Buffer, IP, Port, Verbose)};
{error, Reason}=Err when Reason =:= econnrefused ->
ok = gen_udp:close(S),
{#sock{}, Err};
Reply -> {S, Reply}
end;
Error ->
{S0,Error}
end
Expand Down

0 comments on commit 8cb694b

Please sign in to comment.