Skip to content

Commit bbdf650

Browse files
committed
properly ignore dynamic children that return 'ignore' from init/1
thus preventing an explosion on supervisor shutdown when we would otherwise trip over unlinking an 'undefined' pid.
1 parent f6a1c4b commit bbdf650

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/supervisor2.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ handle_call({start_child, EArgs}, _From, State) when ?is_simple(State) ->
411411
#child{mfa = {M, F, A}} = hd(State#state.children),
412412
Args = A ++ EArgs,
413413
case do_start_child_i(M, F, Args) of
414+
{ok, undefined} ->
415+
{reply, {ok, undefined}, State};
414416
{ok, Pid} ->
415417
NState = State#state{dynamics =
416418
?DICT:store(Pid, Args, State#state.dynamics)},
@@ -743,6 +745,8 @@ restart(Strategy, Child, State, Restart)
743745
#child{mfa = {M, F, A}} = Child,
744746
Dynamics = ?DICT:erase(Child#child.pid, State#state.dynamics),
745747
case do_start_child_i(M, F, A) of
748+
{ok, undefined} ->
749+
{ok, State};
746750
{ok, Pid} ->
747751
NState = State#state{dynamics = ?DICT:store(Pid, A, Dynamics)},
748752
{ok, NState};

0 commit comments

Comments
 (0)