diff options
author | Filipe David Manana <[email protected]> | 2011-03-27 17:51:59 +0100 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2011-04-04 11:54:16 +0200 |
commit | 19ca18fa2425d592e7c340f453b6d44c22e00f9b (patch) | |
tree | 3b18f4346431ae342d070157b6ec649236f521dd | |
parent | 8773ee1b029e3443bba5bedd12ba93ba59a6ea78 (diff) | |
download | otp-19ca18fa2425d592e7c340f453b6d44c22e00f9b.tar.gz otp-19ca18fa2425d592e7c340f453b6d44c22e00f9b.tar.bz2 otp-19ca18fa2425d592e7c340f453b6d44c22e00f9b.zip |
Fix issue with temporary children introduced by OTP-9064
The temporary child specs are never removed from the supervisor's state, and
have they're MFA component set to {M, F, undefined} instead of the MFA passed
in the supervisor:start_child/2 call. Subsequent calls to supervisor:restart_child/2
may crash. Stack trace example:
{badarg,[{erlang,apply,[gen_server,start_link,undefined]},
{supervisor,do_start_child,2},{supervisor,handle_call,3},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]}
-rw-r--r-- | lib/stdlib/src/supervisor.erl | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl index 3c5800effa..b511545b96 100644 --- a/lib/stdlib/src/supervisor.erl +++ b/lib/stdlib/src/supervisor.erl @@ -817,8 +817,12 @@ state_del_child(Child, State) -> NChildren = del_child(Child#child.name, State#state.children), State#state{children = NChildren}. +del_child(Name, [Ch|Chs]) when Ch#child.name =:= Name, Ch#child.restart_type =:= temporary -> + [Chs]; del_child(Name, [Ch|Chs]) when Ch#child.name =:= Name -> [Ch#child{pid = undefined} | Chs]; +del_child(Pid, [Ch|Chs]) when Ch#child.pid =:= Pid, Ch#child.restart_type =:= temporary -> + [Chs]; del_child(Pid, [Ch|Chs]) when Ch#child.pid =:= Pid -> [Ch#child{pid = undefined} | Chs]; del_child(Name, [Ch|Chs]) -> |