diff options
author | Emile Joubert <emile@rabbitmq.com> | 2011-11-01 16:47:29 +0000 |
---|---|---|
committer | Emile Joubert <emile@rabbitmq.com> | 2011-11-01 16:47:29 +0000 |
commit | 4810062a5f72d1c83118377178ea7229169aad30 (patch) | |
tree | 627867cbfc8b9e9fc6558d40320f6bd534d9d1b3 | |
parent | 38e1147ba7dc3bf9091d19103ed6fc056dca59c0 (diff) | |
download | rabbitmq-server-4810062a5f72d1c83118377178ea7229169aad30.tar.gz |
Refactor supervisor shutdown
-rw-r--r-- | src/supervisor2.erl | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl index 27115e22..1f758405 100644 --- a/src/supervisor2.erl +++ b/src/supervisor2.erl @@ -685,11 +685,7 @@ terminate_simple_children(Child, Dynamics, SupName) -> end end, {dict:new(), false}, Pids), timer:cancel(TRef), - RestartPerm = case Child#child.restart_type of - permanent -> true; - {permanent, _Delay} -> true; - _ -> false - end, + RestartPerm = restart_permanent(Child#child.restart_type), ReportAcc = fun (NormalErrorFun) -> fun (Pid, ok, Acc) -> Acc; @@ -711,16 +707,19 @@ terminate_simple_children(Child, Dynamics, SupName) -> end, ok, Replies), ok. +restart_permanent(permanent) -> true; +restart_permanent({permanent, _Delay}) -> true; +restart_permanent(_) -> false; + do_terminate(Child, SupName) when Child#child.pid =/= undefined -> ReportError = shutdown_error_reporter(SupName), case shutdown(Child#child.pid, Child#child.shutdown) of ok -> ok; {error, normal} -> - case Child#child.restart_type of - permanent -> ReportError(normal, Child); - {permanent, _Delay} -> ReportError(normal, Child); - _ -> ok + case restart_permanent(Child#child.restart_type) of + true -> ReportError(normal, Child); + false -> ok end; {error, OtherReason} -> ReportError(OtherReason, Child) |