[erlang-bugs] Supervisor.erl erroreously reports error when child exits with normal during shutdown

Matthew Sackman matthew@REDACTED
Fri Aug 20 17:43:50 CEST 2010


Again, is there anyone who can look at this?

On Thu, Aug 12, 2010 at 12:32:18PM +0100, Matthew Sackman wrote:
> (You can guess what I'm hacking on atm...)
> 
> In supervisor, when it terminates a child, if that child happens to have
> exited fractionally early, with normal, the supervisor reports this as
> an error.
> 
> For permanent children, that's likely the right thing to do, but for all
> other types of children it's wrong and leads to polluted logs. Both
> temporary and transient children do not get restarted on normal
> self-destruction, and nor do they get logged about. Just because they
> happen to destruct as the supervisor is trying to stop them shouldn't
> alter this.
> 
> Diff attached.
> 
> Matthew

> --- /usr/local/lib/erlang/lib/stdlib-1.17/src/supervisor.erl	2010-07-22 14:27:32.000000000 +0100
> +++ supervisor.erl	2010-08-12 12:31:32.000000000 +0100
> @@ -660,14 +660,15 @@
>      Res.
>  
>  do_terminate(Child, SupName) when Child#child.pid =/= undefined ->
> -    case shutdown(Child#child.pid,
> -		  Child#child.shutdown) of
> -	ok ->
> -	    Child#child{pid = undefined};
> -	{error, OtherReason} ->
> -	    report_error(shutdown_error, OtherReason, Child, SupName),
> -	    Child#child{pid = undefined}
> -    end;
> +    case shutdown(Child#child.pid, Child#child.shutdown) of
> +        ok ->
> +            ok;
> +        {error, normal} when Child#child.restart_type =/= permanent ->
> +            ok;
> +        {error, OtherReason} ->
> +            report_error(shutdown_error, OtherReason, Child, SupName)
> +    end,
> +    Child#child{pid = undefined};
>  do_terminate(Child, _SupName) ->
>      Child.
>  
> 

> 
> ________________________________________________________________
> erlang-bugs (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-bugs-unsubscribe@REDACTED



More information about the erlang-bugs mailing list