summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-11-02 12:29:39 +0000
committerSimon MacMullen <simon@rabbitmq.com>2011-11-02 12:29:39 +0000
commit4f379f9953342acece88c552e0f0e05695dd1935 (patch)
tree49b51962d924538f536328663bf9910b7b743382
parentaab5200e1eb2deeb83ac3d313ca040d839c5cf78 (diff)
downloadrabbitmq-server-4f379f9953342acece88c552e0f0e05695dd1935.tar.gz
Refactor: simplify by checking if restart is permanent earlier.
-rw-r--r--src/supervisor2.erl21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl
index f8d38a97..0e7b71b2 100644
--- a/src/supervisor2.erl
+++ b/src/supervisor2.erl
@@ -669,7 +669,7 @@ terminate_simple_children(Child, Dynamics, SupName) ->
{{error, Reason}, true}
end;
{'DOWN', _MRef, process, Pid, Reason} ->
- {child_result(Child, Reason, Timedout), Timedout};
+ {child_res(Child, Reason, Timedout), Timedout};
{'EXIT', Pid, Reason} ->
receive {'DOWN', _MRef, process, Pid, _} ->
{{error, Reason}, Timedout}
@@ -684,15 +684,8 @@ terminate_simple_children(Child, Dynamics, SupName) ->
0 -> ok
end,
ReportError = shutdown_error_reporter(SupName),
- dict:map(fun (_Pid, ok) ->
- ok;
- (Pid, {error, normal}) ->
- case restart_permanent(Child#child.restart_type) of
- true -> ReportError(normal, Child#child{pid = Pid});
- false -> ok
- end;
- (Pid, {error, Reason}) ->
- ReportError(Reason, Child#child{pid = Pid})
+ dict:map(fun (_Pid, ok) -> ok;
+ (Pid, {error, R}) -> ReportError(R, Child#child{pid = Pid})
end, Replies),
ok.
@@ -702,9 +695,11 @@ child_exit_reason(#child{}) -> shutdown.
child_timeout(#child{shutdown = brutal_kill}) -> infinity;
child_timeout(#child{shutdown = Time}) -> Time.
-child_result(#child{shutdown = brutal_kill}, killed, false) -> ok;
-child_result(#child{}, shutdown, false) -> ok;
-child_result(#child{}, R, _) -> {error, R}.
+child_res(#child{shutdown = brutal_kill}, killed, false) -> ok;
+child_res(#child{}, shutdown, false) -> ok;
+child_res(#child{restart_type = permanent}, normal, false) -> ok;
+child_res(#child{restart_type = {permanent, _}}, normal, false) -> ok;
+child_res(#child{}, R, _) -> {error, R}.
restart_permanent(permanent) -> true;
restart_permanent({permanent, _Delay}) -> true;