diff options
| author | Vlad Alexandru Ionescu <vlad@rabbitmq.com> | 2011-03-30 11:47:30 +0100 |
|---|---|---|
| committer | Vlad Alexandru Ionescu <vlad@rabbitmq.com> | 2011-03-30 11:47:30 +0100 |
| commit | c8d207b631931c5b4f40399dabd91e2cad428de7 (patch) | |
| tree | 8336f8b295e6db4c32e2e6264a677d053ec757f9 /src | |
| parent | e33d6ea4f6034a27e5719bf425458be1496dc819 (diff) | |
| download | rabbitmq-server-git-c8d207b631931c5b4f40399dabd91e2cad428de7.tar.gz | |
adding reporting exception to supervisor2
Diffstat (limited to 'src')
| -rw-r--r-- | src/supervisor2.erl | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl index 1a240856ce..2c0874abf9 100644 --- a/src/supervisor2.erl +++ b/src/supervisor2.erl @@ -38,6 +38,10 @@ %% child is a supervisor and it exits normally (i.e. with reason of %% 'shutdown') then the child's parent also exits normally. %% +%% 5) Added an exception to reporting: If a child has MaxR = 0 and it +%% terminates with reason {shutdown, _}, then supervisor2 behaves +%% as supervisor *except* it does not report anything to error_logger. +%% %% All modifications are (C) 2010-2011 VMware, Inc. %% %% %CopyrightBegin% @@ -542,8 +546,7 @@ do_restart({RestartType, Delay}, Reason, Child, State) -> {ok, state_del_child(Child, NState)} end; do_restart(permanent, Reason, Child, State) -> - report_error(child_terminated, Reason, Child, State#state.name), - restart(Child, State); + maybe_report_and_restart(Reason, Child, State); do_restart(intrinsic, normal, Child, State) -> {shutdown, state_del_child(Child, State)}; do_restart(intrinsic, shutdown, Child = #child{child_type = supervisor}, @@ -557,13 +560,24 @@ do_restart(_, shutdown, Child, State) -> {ok, NState}; do_restart(Type, Reason, Child, State) when Type =:= transient orelse Type =:= intrinsic -> - report_error(child_terminated, Reason, Child, State#state.name), - restart(Child, State); + maybe_report_and_restart(Reason, Child, State); do_restart(temporary, Reason, Child, State) -> - report_error(child_terminated, Reason, Child, State#state.name), + maybe_report(Reason, Child, State), NState = state_del_child(Child, State), {ok, NState}. +maybe_report_and_restart({shutdown, _}, Child, State = #state{intensity = 0}) -> + {terminate, NState} = add_restart(State), + {shutdown, state_del_child(Child, NState)}; +maybe_report_and_restart(Reason, Child, State) -> + report_error(child_terminated, Reason, Child, State#state.name), + restart(Child, State). + +maybe_report({shutdown, _}, _Child, #state{intensity = 0}) -> + ok; +maybe_report(Reason, Child, State) -> + report_error(child_terminated, Reason, Child, State#state.name). + restart(Child, State) -> case add_restart(State) of {ok, NState} -> |
