summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Dyachkov <ivan.dyachkov@klarna.com>2012-03-21 12:58:44 +0000
committerIvan Dyachkov <ivan.dyachkov@klarna.com>2012-03-21 12:58:44 +0000
commit33bf55fd7ea946b467262a9fe40aae03dc1c00fa (patch)
treedcdbcb4d958007b8d2209514df9f6ccd8f9ee267
parent489ce88ea57c18c4020e8f1bdaeabdc4d5c46097 (diff)
downloadrabbitmq-server-33bf55fd7ea946b467262a9fe40aae03dc1c00fa.tar.gz
Apply supplied patch to support normal/shutdown termination of delayed restart children
-rw-r--r--src/supervisor2.erl25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl
index a2f4fae9..d3851c4b 100644
--- a/src/supervisor2.erl
+++ b/src/supervisor2.erl
@@ -529,16 +529,8 @@ restart_child(Pid, Reason, State) ->
{ok, State}
end.
-do_restart({RestartType, Delay}, Reason, Child, State) ->
- case restart1(Child, State) of
- {ok, NState} ->
- {ok, NState};
- {terminate, NState} ->
- _TRef = erlang:send_after(trunc(Delay*1000), self(),
- {delayed_restart,
- {{RestartType, Delay}, Reason, Child}}),
- {ok, state_del_child(Child, NState)}
- end;
+do_restart({permanent = RestartType, Delay}, Reason, Child, State) ->
+ do_restart_delay({RestartType, Delay}, Reason, Child, State);
do_restart(permanent, Reason, Child, State) ->
report_error(child_terminated, Reason, Child, State#state.name),
restart(Child, State);
@@ -552,11 +544,24 @@ do_restart(Type, Reason, Child, State) when Type =:= transient orelse
Type =:= intrinsic ->
report_error(child_terminated, Reason, Child, State#state.name),
restart(Child, State);
+do_restart({transient = RestartType, Delay}, Reason, Child, State) ->
+ do_restart_delay({RestartType, Delay}, Reason, Child, State);
do_restart(temporary, Reason, Child, State) ->
report_error(child_terminated, Reason, Child, State#state.name),
NState = state_del_child(Child, State),
{ok, NState}.
+do_restart_delay({RestartType, Delay}, Reason, Child, State) ->
+ case restart1(Child, State) of
+ {ok, NState} ->
+ {ok, NState};
+ {terminate, NState} ->
+ _TRef = erlang:send_after(trunc(Delay*1000), self(),
+ {delayed_restart,
+ {{RestartType, Delay}, Reason, Child}}),
+ {ok, state_del_child(Child, NState)}
+ end.
+
del_child_and_maybe_shutdown(intrinsic, Child, State) ->
{shutdown, state_del_child(Child, State)};
del_child_and_maybe_shutdown(_, Child, State) ->