summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Alexandru Ionescu <vlad@rabbitmq.com>2011-03-30 11:47:30 +0100
committerVlad Alexandru Ionescu <vlad@rabbitmq.com>2011-03-30 11:47:30 +0100
commitd8f2e891ce8c4a42184e084b582724546c379495 (patch)
tree8336f8b295e6db4c32e2e6264a677d053ec757f9
parent88f1f2f23d4cc3cbd4612f72d1cd40830aa2c8b6 (diff)
downloadrabbitmq-server-d8f2e891ce8c4a42184e084b582724546c379495.tar.gz
adding reporting exception to supervisor2
-rw-r--r--src/supervisor2.erl24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl
index 1a240856..2c0874ab 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} ->