mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Avoid a possible race condition
This commit is contained in:
parent
07cfc000ea
commit
1f97740cfa
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
%% API:
|
%% API:
|
||||||
-export([start/2,
|
-export([start/2,
|
||||||
|
preinit/2,
|
||||||
init/1,
|
init/1,
|
||||||
stop/1]).
|
stop/1]).
|
||||||
-export([update_bl_c2s/0]).
|
-export([update_bl_c2s/0]).
|
||||||
@ -49,14 +50,20 @@
|
|||||||
-record(bl_c2s, {ip}).
|
-record(bl_c2s, {ip}).
|
||||||
|
|
||||||
%% Start once for all vhost
|
%% Start once for all vhost
|
||||||
start(Host, Opts) ->
|
start(_Host, _Opts) ->
|
||||||
case whereis(?PROCNAME) of
|
Pid = spawn(?MODULE, preinit, [self(), #state{}]),
|
||||||
undefined ->
|
receive {ok, Pid, PreinitResult} ->
|
||||||
?DEBUG("Starting mod_ip_blacklist ~p ~p~n", [Host, Opts]),
|
PreinitResult
|
||||||
register(?PROCNAME,
|
end.
|
||||||
spawn(?MODULE, init, [#state{}]));
|
|
||||||
_ ->
|
preinit(Parent, State) ->
|
||||||
ok
|
Pid = self(),
|
||||||
|
try register(?PROCNAME, Pid) of
|
||||||
|
true ->
|
||||||
|
Parent ! {ok, Pid, true},
|
||||||
|
init(State)
|
||||||
|
catch error:_ ->
|
||||||
|
Parent ! {ok, Pid, true}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% TODO:
|
%% TODO:
|
||||||
|
Loading…
Reference in New Issue
Block a user