25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

* src/ejabberd_sm.erl: Now delivering messages to all resources with

max equal priority when this priority is non-negative.

SVN Revision: 541
This commit is contained in:
Mickaël Rémond 2006-04-23 09:31:54 +00:00
parent dc198cf08e
commit c86275ce9d
2 changed files with 25 additions and 14 deletions

View File

@ -2,6 +2,8 @@
* src/msgs/fr.msg: Updated * src/msgs/fr.msg: Updated
* src/msgs/de.msg: Updated (thanks to Nikolaus Polak) * src/msgs/de.msg: Updated (thanks to Nikolaus Polak)
* src/ejabberd_sm.erl: Now delivering messages to all resources with
max equal priority when this priority is non-negative.
2006-04-22 Alexey Shchepin <alexey@sevcom.net> 2006-04-22 Alexey Shchepin <alexey@sevcom.net>

View File

@ -432,20 +432,29 @@ do_route(From, To, Packet) ->
route_message(From, To, Packet) -> route_message(From, To, Packet) ->
LUser = To#jid.luser, LUser = To#jid.luser,
LServer = To#jid.lserver, LServer = To#jid.lserver,
case catch lists:max(get_user_present_resources(LUser, LServer)) of PrioRes = get_user_present_resources(LUser, LServer),
{Priority, R} when is_integer(Priority), case catch lists:max(PrioRes) of
Priority >= 0 -> {Priority, _R} when is_integer(Priority), Priority >= 0 ->
LResource = jlib:resourceprep(R), lists:foreach(
USR = {LUser, LServer, LResource}, %% Route messages to all priority that equals the max, if
case mnesia:dirty_index_read(session, USR, #session.usr) of %% positive
[] -> fun({P, R}) when P == Priority ->
ok; % Race condition LResource = jlib:resourceprep(R),
Ss -> USR = {LUser, LServer, LResource},
Session = lists:max(Ss), case mnesia:dirty_index_read(session, USR, #session.usr) of
Pid = element(2, Session#session.sid), [] ->
?DEBUG("sending to process ~p~n", [Pid]), ok; % Race condition
Pid ! {route, From, To, Packet} Ss ->
end; 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 case xml:get_tag_attr_s("type", Packet) of
"error" -> "error" ->