From 25449a076fa2c338f243ee9532820d9aa1eed7ad Mon Sep 17 00:00:00 2001 From: Badlop Date: Fri, 10 Apr 2015 16:02:45 +0200 Subject: [PATCH] Clean multicast routing code detected by xref --- src/ejabberd_router_multicast.erl | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/src/ejabberd_router_multicast.erl b/src/ejabberd_router_multicast.erl index e438fefdb..9cd7dd3dd 100644 --- a/src/ejabberd_router_multicast.erl +++ b/src/ejabberd_router_multicast.erl @@ -196,42 +196,18 @@ do_route(From, Domain, Destinations, Packet) -> [jlib:jid_to_string(To) || To <- Destinations], 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 case mnesia:dirty_read(route_multicast, Domain) of %% 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 [R] -> case R#route_multicast.pid of Pid when is_pid(Pid) -> - Pid ! {route_trusted, From, Rest, Packet}; - _ -> do_route_normal(From, Rest, Packet) + Pid ! {route_trusted, From, Destinations, Packet}; + _ -> do_route_normal(From, Destinations, Packet) end end.