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

Fix race condition (EJABS-1677)

This commit is contained in:
Evgeniy Khramtsov 2011-05-30 16:51:55 +10:00 committed by Christophe Romain
parent 133b8d42a3
commit f0c32433dc

View File

@ -233,8 +233,16 @@ handle_cast(_Msg, State) ->
handle_info({timeout, _TRef, {ID, Pid}}, State) -> handle_info({timeout, _TRef, {ID, Pid}}, State) ->
case lookup(Pid, ID, State#state.timers) of case lookup(Pid, ID, State#state.timers) of
{ok, _} -> {ok, _} ->
catch ejabberd_c2s:stop(Pid), MRef = erlang:monitor(process, Pid),
handle_cast({del, Pid}, State); catch ejabberd_c2s:stop(Pid),
receive
{'DOWN', MRef, process, Pid, _Reason}->
ok
after 5 ->
catch exit(Pid, kill)
end,
erlang:demonitor(MRef, [flush]),
handle_cast({del, Pid}, State);
error -> error ->
{noreply, State} {noreply, State}
end; end;