]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_sm.erl (do_route/3): Minor fix
authorAlexey Shchepin <alexey@process-one.net>
Fri, 2 Jan 2004 19:36:38 +0000 (19:36 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Fri, 2 Jan 2004 19:36:38 +0000 (19:36 +0000)
* src/ejabberd_sm.erl (route_message/3): Minor changes

SVN Revision: 194

ChangeLog
src/ejabberd_sm.erl

index f6852f306c4f0f0931bbbb6c4a03ae3b82f1b3d1..271a23a3fb29c16c8fa4d429140438bb5a0deb8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-01-01  Alexey Shchepin  <alexey@sevcom.net>
+
+       * src/ejabberd_sm.erl (do_route/3): Minor fix
+
+       * src/ejabberd_sm.erl (route_message/3): Minor changes
+
 2003-12-28  Alexey Shchepin  <alexey@sevcom.net>
 
        * src/ejabberd_app.erl: Now possible to specify path to log file
index 03d1cac963371918bcf7eb80f78e8f03aeebafb0..628aa6bdee80e03c6be283ef280f3bac724122e2 100644 (file)
@@ -177,11 +177,11 @@ do_route(From, To, Packet) ->
                        end,
                    if Pass ->
                            LFrom = jlib:jid_tolower(From),
-                           Resources = get_user_resources(User),
+                           PResources = get_user_present_resources(User),
                            if
-                               Resources /= [] ->
+                               PResources /= [] ->
                                    lists:foreach(
-                                     fun(R) ->
+                                     fun({_, R}) ->
                                              if LFrom /=
                                                 {LUser, LServer, R} ->
                                                      ejabberd_sm !
@@ -192,7 +192,7 @@ do_route(From, To, Packet) ->
                                                 true ->
                                                      ok
                                              end
-                                     end, Resources);
+                                     end, PResources);
                                true ->
                                    if
                                        Subsc ->
@@ -248,7 +248,7 @@ do_route(From, To, Packet) ->
     end.
 
 route_message(From, To, Packet) ->
-    #jid{luser = LUser} = To,
+    LUser = To#jid.luser,
     case catch lists:max(get_user_present_resources(LUser)) of
        {'EXIT', _} ->
            case xml:get_tag_attr_s("type", Packet) of
@@ -273,10 +273,16 @@ route_message(From, To, Packet) ->
                    end
            end;
        {_, R} ->
-           ejabberd_sm ! {route,
-                          From,
-                          jlib:jid_replace_resource(To, R),
-                          Packet}
+           LResource = jlib:resourceprep(R),
+           LUR = {LUser, LResource},
+           case mnesia:dirty_read({session, LUR}) of
+               [] ->
+                   ok;                         % Race condition
+               [Sess] ->
+                   Pid = Sess#session.pid,
+                   ?DEBUG("sending to process ~p~n", [Pid]),
+                   Pid ! {route, From, To, Packet}
+           end
     end.