diff options
author | Tim Watson <tim@rabbitmq.com> | 2013-03-11 14:34:39 +0000 |
---|---|---|
committer | Tim Watson <tim@rabbitmq.com> | 2013-03-11 14:34:39 +0000 |
commit | e4b8ffb341f1141ebd897b00e43a0640a8fab693 (patch) | |
tree | 503e596583d9e40445833b74b022ceb34b2e7e8d | |
parent | fe1f803340caa83e9737399d9bb0148c9d8a9d10 (diff) | |
download | rabbitmq-server-e4b8ffb341f1141ebd897b00e43a0640a8fab693.tar.gz |
track repeated attempts to restart properly
-rw-r--r-- | src/supervisor2.erl | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl index ff519acd..a181e7d4 100644 --- a/src/supervisor2.erl +++ b/src/supervisor2.erl @@ -650,25 +650,15 @@ handle_cast({try_again_restart,Pid,Reason}, #state{children=[Child]}=State) {ok, Args} -> {M, F, _} = Child#child.mfargs, NChild = Child#child{pid = RPid, mfargs = {M, F, Args}}, - case restart_child(NChild,Reason,State) of - {ok, State1} -> - {noreply, State1}; - {shutdown, State1} -> - {stop, shutdown, State1} - end; + try_restart(Child#child.restart_type, Reason, NChild, State); error -> {noreply, State} end; handle_cast({try_again_restart,Name,Reason}, State) -> case lists:keyfind(Name,#child.name,State#state.children) of - Child = #child{pid=?restarting(_)} -> - case restart_child(Child,Reason,State) of - {ok, State1} -> - {noreply, State1}; - {shutdown, State1} -> - {stop, shutdown, State1} - end; + Child = #child{pid=?restarting(_), restart_type=RestartType} -> + try_restart(RestartType, Reason, Child, State); _ -> {noreply,State} end. @@ -690,11 +680,11 @@ handle_info({'EXIT', Pid, Reason}, State) -> handle_info({delayed_restart, {RestartType, Reason, Child}}, State) when ?is_simple(State) -> - delayed_restart(RestartType, Reason, Child, State); + try_restart(RestartType, Reason, Child, State); handle_info({delayed_restart, {RestartType, Reason, Child}}, State) -> case get_child(Child#child.name, State) of {value, Child1} -> - delayed_restart(RestartType, Reason, Child1, State); + try_restart(RestartType, Reason, Child1, State); _What -> {noreply, State} end; @@ -704,12 +694,6 @@ handle_info(Msg, State) -> [Msg]), {noreply, State}. -delayed_restart(RestartType, Reason, Child, State) -> - case do_restart(RestartType, Reason, Child, State) of - {ok, NState} -> {noreply, NState}; - {shutdown, State2} -> {stop, shutdown, State2} - end. - %% %% Terminate this server. %% @@ -853,6 +837,12 @@ restart_child(Pid, Reason, State) -> {ok, State} end. +try_restart(RestartType, Reason, Child, State) -> + case do_restart(RestartType, Reason, Child, State) of + {ok, NState} -> {noreply, NState}; + {shutdown, State2} -> {stop, shutdown, State2} + end. + do_restart(RestartType, Reason, Child, State) -> maybe_report_error(RestartType, Reason, Child, State), handle_restart(RestartType, Reason, Child, State). |