From 726545ae86958cec2d58c3f1d3e1c97cf5831355 Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Thu, 24 Sep 2009 19:29:21 +0000 Subject: [PATCH] improve waiting caps clean (EJAB-1054) SVN Revision: 2627 --- src/mod_caps.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mod_caps.erl b/src/mod_caps.erl index 6432c4872..0b8eea75e 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -149,6 +149,8 @@ get_user_resources(LUser, LServer) -> note_caps(Host, From, Caps) -> case Caps of nothing -> + BJID = jid_to_binary(From), + catch mnesia:dirty_delete({user_caps, BJID}), ok; _ -> Proc = gen_mod:get_module_proc(Host, ?PROCNAME), @@ -362,7 +364,7 @@ handle_cast({note_caps, From, ejabberd_local:register_iq_response_handler (Host, ID, ?MODULE, handle_disco_response), ejabberd_router:route(jlib:make_jid("", Host, ""), From, Stanza), - timer:send_after(?CAPS_QUERY_TIMEOUT, self(), {disco_timeout, ID}), + timer:send_after(?CAPS_QUERY_TIMEOUT, self(), {disco_timeout, ID, BJID}), ?DICT:store(ID, node_to_binary(Node, SubNode), Dict) end, Requests, Missing), {noreply, State#state{disco_requests = NewRequests}} @@ -409,10 +411,11 @@ handle_cast({disco_response, From, _To, end, NewRequests = ?DICT:erase(ID, Requests), {noreply, State#state{disco_requests = NewRequests}}; -handle_cast({disco_timeout, ID}, #state{host = Host, disco_requests = Requests} = State) -> +handle_cast({disco_timeout, ID, BJID}, #state{host = Host, disco_requests = Requests} = State) -> %% do not wait a response anymore for this IQ, client certainly will never answer NewRequests = case ?DICT:is_key(ID, Requests) of true -> + catch mnesia:dirty_delete({user_caps, BJID}), ejabberd_local:unregister_iq_response_handler(Host, ID), ?DICT:erase(ID, Requests); false ->