aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/inet_res.erl
diff options
context:
space:
mode:
authorRaimo Niskanen <raimo@erlang.org>2011-04-15 09:25:47 +0200
committerRaimo Niskanen <raimo@erlang.org>2011-04-21 08:54:13 +0200
commitfded0077e780b1167227a41a41b6aad39cb37eb2 (patch)
tree1acd78ad510c8ffe6765471d41cf7cf60d63f43e /lib/kernel/src/inet_res.erl
parent291644e89541f87496c44aacf21ae7a228d1f018 (diff)
downloadotp-fded0077e780b1167227a41a41b6aad39cb37eb2.tar.gz
otp-fded0077e780b1167227a41a41b6aad39cb37eb2.tar.bz2
otp-fded0077e780b1167227a41a41b6aad39cb37eb2.zip
Check return values from UDP send functions
Diffstat (limited to 'lib/kernel/src/inet_res.erl')
-rw-r--r--lib/kernel/src/inet_res.erl54
1 files changed, 32 insertions, 22 deletions
diff --git a/lib/kernel/src/inet_res.erl b/lib/kernel/src/inet_res.erl
index 2b63121043..962dd82ac9 100644
--- a/lib/kernel/src/inet_res.erl
+++ b/lib/kernel/src/inet_res.erl
@@ -694,28 +694,38 @@ query_ns(S0, Id, Buffer, IP, Port, Timer, Retry, I,
query_udp(S, Id, Buffer, IP, Port, Timeout, Verbose) ->
?verbose(Verbose, "Try UDP server : ~p:~p (timeout=~w)\n",
[IP,Port,Timeout]),
- udp_connect(S, IP, Port),
- udp_send(S, IP, Port, Buffer),
- Decode =
- fun ({RecIP,RecPort,Answer}) when RecIP =:= IP, RecPort =:= Port ->
- case decode_answer(Answer, Id, Verbose) of
- {error,badid} ->
- false;
- Reply ->
- Reply
- end;
- ({_,_,_}) ->
- false
- end,
- case udp_recv(S, IP, Port, Timeout, Decode) of
- {ok,_}=Result ->
- Result;
- {error,timeout} when Timeout =:= 0 ->
- ?verbose(Verbose, "UDP bailout timeout\n", []),
- timeout;
- Error ->
- ?verbose(Verbose, "UDP server error: ~p\n", [Error]),
- Error
+ case
+ case udp_connect(S, IP, Port) of
+ ok ->
+ udp_send(S, IP, Port, Buffer);
+ E1 ->
+ E1 end of
+ ok ->
+ Decode =
+ fun ({RecIP,RecPort,Answer})
+ when RecIP =:= IP, RecPort =:= Port ->
+ case decode_answer(Answer, Id, Verbose) of
+ {error,badid} ->
+ false;
+ Reply ->
+ Reply
+ end;
+ ({_,_,_}) ->
+ false
+ end,
+ case udp_recv(S, IP, Port, Timeout, Decode) of
+ {ok,_}=Result ->
+ Result;
+ {error,timeout} when Timeout =:= 0 ->
+ ?verbose(Verbose, "UDP bailout timeout\n", []),
+ timeout;
+ E2 ->
+ ?verbose(Verbose, "UDP server error: ~p\n", [E2]),
+ E2
+ end;
+ E3 ->
+ ?verbose(Verbose, "UDP send failed: ~p\n", [E3]),
+ {error,econnrefused}
end.
query_tcp(Timeout, Id, Buffer, IP, Port, Verbose) ->