mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Fix race condition in Redis/SQL supervisors startup
This commit is contained in:
parent
86c4f76c51
commit
72f6835feb
@ -45,7 +45,10 @@ start() ->
|
|||||||
permanent, infinity, supervisor, [?MODULE]},
|
permanent, infinity, supervisor, [?MODULE]},
|
||||||
case supervisor:start_child(ejabberd_db_sup, Spec) of
|
case supervisor:start_child(ejabberd_db_sup, Spec) of
|
||||||
{ok, _} -> ok;
|
{ok, _} -> ok;
|
||||||
{error, {already_started, _}} -> ok;
|
{error, {already_started, Pid}} ->
|
||||||
|
%% Wait for the supervisor to fully start
|
||||||
|
_ = supervisor:count_children(Pid),
|
||||||
|
ok;
|
||||||
{error, Why} = Err ->
|
{error, Why} = Err ->
|
||||||
?ERROR_MSG("Failed to start ~ts: ~p", [?MODULE, Why]),
|
?ERROR_MSG("Failed to start ~ts: ~p", [?MODULE, Why]),
|
||||||
Err
|
Err
|
||||||
|
@ -52,7 +52,10 @@ start(Host) ->
|
|||||||
modules => [?MODULE]},
|
modules => [?MODULE]},
|
||||||
case supervisor:start_child(ejabberd_db_sup, Spec) of
|
case supervisor:start_child(ejabberd_db_sup, Spec) of
|
||||||
{ok, _} -> ok;
|
{ok, _} -> ok;
|
||||||
{error, {already_started, _}} -> ok;
|
{error, {already_started, Pid}} ->
|
||||||
|
%% Wait for the supervisor to fully start
|
||||||
|
_ = supervisor:count_children(Pid),
|
||||||
|
ok;
|
||||||
{error, Why} = Err ->
|
{error, Why} = Err ->
|
||||||
?ERROR_MSG("Failed to start ~ts: ~p", [?MODULE, Why]),
|
?ERROR_MSG("Failed to start ~ts: ~p", [?MODULE, Why]),
|
||||||
Err
|
Err
|
||||||
|
Loading…
Reference in New Issue
Block a user