]> granicus.if.org Git - ejabberd/commitdiff
- pass jid into feature_check_packet hook;
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Wed, 17 Mar 2010 14:40:48 +0000 (23:40 +0900)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Wed, 17 Mar 2010 14:40:48 +0000 (23:40 +0900)
- bounce messages when closing c2s session;
- implemented treap:to_list/1 and treap:from_list/1

src/ejabberd_c2s.erl
src/treap.erl

index 6df6766ca9a5cc7e32ca12d580e81d9c021407b1..ef4614aa291a9df0b6620b0ba6e6e857edf5c26a 100644 (file)
@@ -1276,7 +1276,7 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
                        case ejabberd_hooks:run_fold(
                               feature_check_packet, StateData#state.server,
                               allow,
-                              [StateData#state.user,
+                              [StateData#state.jid,
                                StateData#state.server,
                                StateData#state.pres_last,
                                {From, To, Packet},
@@ -1392,7 +1392,8 @@ terminate(_Reason, StateName, StateData) ->
                            presence_broadcast(
                              StateData, From, StateData#state.pres_i, Packet)
                    end
-           end;
+           end,
+           bounce_messages();
        _ ->
            ok
     end,
@@ -2185,6 +2186,15 @@ fsm_limit_opts(Opts) ->
            end
     end.
 
+bounce_messages() ->
+    receive
+       {route, From, To, El} ->
+           ejabberd_router:route(From, To, El),
+           bounce_messages()
+    after 0 ->
+           ok
+    end.
+
 %%%----------------------------------------------------------------------
 %%% JID Set memory footprint reduction code
 %%%----------------------------------------------------------------------
index 61cfe7017f65957fe580a980275f142b1676d962..a5ed9b93b20e9bd4f13e7ff687ef5753bf94a983 100644 (file)
@@ -33,7 +33,9 @@
         get_root/1,
         lookup/2,
         is_empty/1,
-        fold/3]).
+        fold/3,
+        from_list/1,
+        to_list/1]).
 
 empty() ->
     nil.
@@ -173,3 +175,20 @@ fold(F, Acc, {{_Hash, Key}, Priority, Value, Left, Right}) ->
     Acc1 = F({Key, Priority, Value}, Acc),
     Acc2 = fold(F, Acc1, Left),
     fold(F, Acc2, Right).
+
+to_list(Tree) ->
+    to_list(Tree, []).
+
+to_list(nil, Acc) ->
+    Acc;
+to_list(Tree, Acc) ->
+    Root = get_root(Tree),
+    to_list(delete_root(Tree), [Root|Acc]).
+
+from_list(List) ->
+    from_list(List, nil).
+
+from_list([{Key, Priority, Value}|Tail], Tree) ->
+    from_list(Tail, insert(Key, Priority, Value, Tree));
+from_list([], Tree) ->
+    Tree.