26
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Reorganize the code to shut up the dialyzer

This commit is contained in:
Evgeniy Khramtsov 2011-09-05 21:27:31 +10:00
parent f3c90ee266
commit 6b0eb1f09d

View File

@ -1073,33 +1073,29 @@ get_addr_port(Server) ->
{ok, HEnt} -> {ok, HEnt} ->
?DEBUG("srv lookup of '~s': ~p~n", ?DEBUG("srv lookup of '~s': ~p~n",
[Server, HEnt#hostent.h_addr_list]), [Server, HEnt#hostent.h_addr_list]),
case HEnt#hostent.h_addr_list of AddrList = HEnt#hostent.h_addr_list,
[] -> %% Probabilities are not exactly proportional to weights
[{Server, outgoing_s2s_port()}]; %% for simplicity (higher weigths are overvalued)
AddrList -> {A1, A2, A3} = now(),
%% Probabilities are not exactly proportional to weights random:seed(A1, A2, A3),
%% for simplicity (higher weigths are overvalued) case (catch lists:map(
{A1, A2, A3} = now(), fun({Priority, Weight, Port, Host}) ->
random:seed(A1, A2, A3), N = case Weight of
case (catch lists:map( 0 -> 0;
fun({Priority, Weight, Port, Host}) -> _ -> (Weight + 1) * random:uniform()
N = case Weight of end,
0 -> 0; {Priority * 65536 - N, Host, Port}
_ -> (Weight + 1) * random:uniform() end, AddrList)) of
end, SortedList = [_|_] ->
{Priority * 65536 - N, Host, Port} List = lists:map(
end, AddrList)) of fun({_, Host, Port}) ->
{'EXIT', _Reason} -> {Host, Port}
[{Server, outgoing_s2s_port()}]; end, lists:keysort(1, SortedList)),
SortedList -> ?DEBUG("srv lookup of '~s': ~p~n", [Server, List]),
List = lists:map( List;
fun({_, Host, Port}) -> _ ->
{Host, Port} [{Server, outgoing_s2s_port()}]
end, lists:keysort(1, SortedList)), end
?DEBUG("srv lookup of '~s': ~p~n", [Server, List]),
List
end
end
end. end.
srv_lookup(Server) -> srv_lookup(Server) ->