25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-08 15:42:29 +01:00

Clean multicast routing code detected by xref

This commit is contained in:
Badlop 2015-04-10 16:02:45 +02:00
parent b9fdcc3985
commit 25449a076f

View File

@ -196,42 +196,18 @@ do_route(From, Domain, Destinations, Packet) ->
[jlib:jid_to_string(To) || To <- Destinations], [jlib:jid_to_string(To) || To <- Destinations],
Packet]), Packet]),
{Groups, Rest} = lists:foldr(
fun(Dest, {Groups1, Rest1}) ->
case ejabberd_sm:get_session_pid(Dest#jid.luser, Dest#jid.lserver, Dest#jid.lresource) of
none ->
{Groups1, [Dest|Rest1]};
Pid ->
Node = node(Pid),
if Node /= node() ->
{dict:append(Node, Dest, Groups1), Rest1};
true ->
{Groups1, [Dest|Rest1]}
end
end
end, {dict:new(), []}, Destinations),
dict:map(
fun(Node, [Single]) ->
ejabberd_cluster:send({ejabberd_sm, Node},
{route, From, Single, Packet});
(Node, Dests) ->
ejabberd_cluster:send({ejabberd_sm, Node},
{route_multiple, From, Dests, Packet})
end, Groups),
%% Try to find an appropriate multicast service %% Try to find an appropriate multicast service
case mnesia:dirty_read(route_multicast, Domain) of case mnesia:dirty_read(route_multicast, Domain) of
%% If no multicast service is available in this server, send manually %% If no multicast service is available in this server, send manually
[] -> do_route_normal(From, Rest, Packet); [] -> do_route_normal(From, Destinations, Packet);
%% If available, send the packet using multicast service %% If available, send the packet using multicast service
[R] -> [R] ->
case R#route_multicast.pid of case R#route_multicast.pid of
Pid when is_pid(Pid) -> Pid when is_pid(Pid) ->
Pid ! {route_trusted, From, Rest, Packet}; Pid ! {route_trusted, From, Destinations, Packet};
_ -> do_route_normal(From, Rest, Packet) _ -> do_route_normal(From, Destinations, Packet)
end end
end. end.