Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <xramtsov@gmail.com>2009-09-25 15:47:21 +0400
committerEvgeniy Khramtsov <xramtsov@gmail.com>2009-09-25 15:47:21 +0400
commit6fa0f6823966bd874a234315b94756ab368cdcc4 (patch)
tree1348eaed210cacb1269e24951399cad0711dc655 /src/mod_caps.erl
parenta126a1883ee41d1368c9012183be6372d5d33c3c (diff)
fixes race condition in wait_caps/note_caps (EJAB-1054)
SVN Revision: 2632
Diffstat (limited to 'src/mod_caps.erl')
-rw-r--r--src/mod_caps.erl15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/mod_caps.erl b/src/mod_caps.erl
index 0b8eea75e..42360a668 100644
--- a/src/mod_caps.erl
+++ b/src/mod_caps.erl
@@ -147,15 +147,8 @@ get_user_resources(LUser, LServer) ->
%% information. Host is the host that asks, From is the full JID that
%% sent the caps packet, and Caps is what read_caps returned.
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),
- gen_server:cast(Proc, {note_caps, From, Caps})
- end.
+ Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
+ gen_server:cast(Proc, {note_caps, From, Caps}).
%% wait_caps should be called just before note_caps
%% it allows to lock get_caps usage for code using presence_probe
@@ -318,6 +311,10 @@ handle_call({get_features, Caps}, From, State) ->
handle_call(stop, _From, State) ->
{stop, normal, ok, State}.
+handle_cast({note_caps, From, nothing}, State) ->
+ BJID = jid_to_binary(From),
+ catch mnesia:dirty_delete({user_caps, BJID}),
+ {noreply, State};
handle_cast({note_caps, From,
#caps{node = Node, version = Version, exts = Exts} = Caps},
#state{host = Host, disco_requests = Requests} = State) ->