summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-08-09 12:32:27 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2010-08-09 12:32:27 +0100
commit8eb8c17d49c98a1c0c33d4a9e0630a7b5a2e2535 (patch)
treeb634b2a5d36ae4d14b873bc760083e9bbc0308f4
parent5a9ac596ab35b378a6efb18d660f5ebb0d433595 (diff)
downloadrabbitmq-server-8eb8c17d49c98a1c0c33d4a9e0630a7b5a2e2535.tar.gz
Introduce intrinsic restart type
-rw-r--r--src/supervisor2.erl17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl
index fb4c9b02..eb2c6bde 100644
--- a/src/supervisor2.erl
+++ b/src/supervisor2.erl
@@ -31,6 +31,14 @@
%% the MaxT and MaxR parameters to permit the child to be
%% restarted. This may require waiting for longer than Delay.
%%
+%% 4) Added an 'intrinsic' restart type. This type means that the
+%% child should never be restarted (same as temporary) but whenever
+%% such a child exits, it will cause the entire supervisor to exit
+%% (i.e. the child's existence is intrinsic to the supervisor's
+%% existence). Because such children are never restarted, the
+%% supervisor's restart strategy, MaxT and MaxR have no bearing on
+%% such children.
+%%
%% All modifications are (C) 2010 Rabbit Technologies Ltd.
%%
%% %CopyrightBegin%
@@ -521,6 +529,12 @@ restart_child(Pid, Reason, State) ->
{ok, State}
end.
+do_restart(intrinsic, Reason, Child, State = #state{name = Name}) ->
+ case Reason of
+ normal -> ok;
+ _ -> report_error(child_terminated, Reason, Child, Name)
+ end,
+ {shutdown, remove_child(Child, State)};
do_restart({RestartType, Delay}, Reason, Child, State) ->
case restart1(Child, State) of
{ok, NState} ->
@@ -834,7 +848,7 @@ supname(N,_) -> N.
%%% where Name is an atom
%%% Func is {Mod, Fun, Args} == {atom, atom, list}
%%% RestartType is permanent | temporary | transient |
-%%% {permanent, Delay} |
+%%% intrinsic | {permanent, Delay} |
%%% {transient, Delay} where Delay >= 0
%%% Shutdown = integer() | infinity | brutal_kill
%%% ChildType = supervisor | worker
@@ -881,6 +895,7 @@ validFunc({M, F, A}) when is_atom(M),
is_list(A) -> true;
validFunc(Func) -> throw({invalid_mfa, Func}).
+validRestartType(intrinsic) -> true;
validRestartType(permanent) -> true;
validRestartType(temporary) -> true;
validRestartType(transient) -> true;