diff options
author | Mickaël Rémond <mickael.remond@process-one.net> | 2006-04-23 09:31:54 +0000 |
---|---|---|
committer | Mickaël Rémond <mickael.remond@process-one.net> | 2006-04-23 09:31:54 +0000 |
commit | c86275ce9daee868d6cc4c540a1d4a2b0a3d8d9f (patch) | |
tree | ded969b9b0a5fcf5510a6d36aaf626728ec88a66 /src/ejabberd_sm.erl | |
parent | * src/msgs/de.msg: Updated (thanks to Nikolaus Polak) (diff) |
* src/ejabberd_sm.erl: Now delivering messages to all resources with
max equal priority when this priority is non-negative.
SVN Revision: 541
Diffstat (limited to 'src/ejabberd_sm.erl')
-rw-r--r-- | src/ejabberd_sm.erl | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 1127ddd09..c9ed39b18 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -432,20 +432,29 @@ do_route(From, To, Packet) -> route_message(From, To, Packet) -> LUser = To#jid.luser, LServer = To#jid.lserver, - case catch lists:max(get_user_present_resources(LUser, LServer)) of - {Priority, R} when is_integer(Priority), - Priority >= 0 -> - LResource = jlib:resourceprep(R), - USR = {LUser, LServer, LResource}, - case mnesia:dirty_index_read(session, USR, #session.usr) of - [] -> - ok; % Race condition - Ss -> - Session = lists:max(Ss), - Pid = element(2, Session#session.sid), - ?DEBUG("sending to process ~p~n", [Pid]), - Pid ! {route, From, To, Packet} - end; + PrioRes = get_user_present_resources(LUser, LServer), + case catch lists:max(PrioRes) of + {Priority, _R} when is_integer(Priority), Priority >= 0 -> + lists:foreach( + %% Route messages to all priority that equals the max, if + %% positive + fun({P, R}) when P == Priority -> + LResource = jlib:resourceprep(R), + USR = {LUser, LServer, LResource}, + case mnesia:dirty_index_read(session, USR, #session.usr) of + [] -> + ok; % Race condition + Ss -> + Session = lists:max(Ss), + Pid = element(2, Session#session.sid), + ?DEBUG("sending to process ~p~n", [Pid]), + Pid ! {route, From, To, Packet} + end; + %% Ignore other priority: + ({_Prio, _Res}) -> + ok + end, + PrioRes); _ -> case xml:get_tag_attr_s("type", Packet) of "error" -> |