diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-12 06:16:57 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-12 06:16:57 +0100 |
| commit | c16a63ee4e19b129c438da7c0e0da4c8bf3785c6 (patch) | |
| tree | 03d0d60c1640df840815e0da7f6d7780331173d3 /src | |
| parent | 7a5439363df2ba639adc5d2a209df75528b30c0d (diff) | |
| download | rabbitmq-server-git-c16a63ee4e19b129c438da7c0e0da4c8bf3785c6.tar.gz | |
do not ignore 'normal' permanent child terminations during shutdown
If such a termination is worth reporting while the supervisor is
running, it sure is still worth reporting when it's shutting down.
This involves reverting all the changes related to ignoring normal
termination during shutdown and instead adding some logic a bit higher
up the call chain.
Diffstat (limited to 'src')
| -rw-r--r-- | src/supervisor2.erl | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl index dc55dbb66c..4d2955d9cd 100644 --- a/src/supervisor2.erl +++ b/src/supervisor2.erl @@ -649,14 +649,22 @@ terminate_simple_children(Child, Dynamics, SupName) -> ok. do_terminate(Child, SupName) when Child#child.pid =/= undefined -> - case shutdown(Child#child.pid, - Child#child.shutdown) of - ok -> - Child#child{pid = undefined}; - {error, OtherReason} -> - report_error(shutdown_error, OtherReason, Child, SupName), - Child#child{pid = undefined} - end; + ReportError = fun (Reason) -> + report_error(shutdown_error, Reason, Child, SupName) + end, + case shutdown(Child#child.pid, Child#child.shutdown) of + ok -> + ok; + {error, normal} -> + case Child#child.restart_type of + permanent -> ReportError(normal); + {permanent, _Delay} -> ReportError(normal); + _ -> ok + end; + {error, OtherReason} -> + ReportError(OtherReason) + end, + Child#child{pid = undefined}; do_terminate(Child, _SupName) -> Child. @@ -676,8 +684,10 @@ shutdown(Pid, brutal_kill) -> ok -> exit(Pid, kill), receive - {'DOWN', _MRef, process, Pid, Reason} -> - check_shutdown_reason(killed, Reason) + {'DOWN', _MRef, process, Pid, killed} -> + ok; + {'DOWN', _MRef, process, Pid, OtherReason} -> + {error, OtherReason} end; {error, Reason} -> {error, Reason} @@ -689,8 +699,10 @@ shutdown(Pid, Time) -> ok -> exit(Pid, shutdown), %% Try to shutdown gracefully receive - {'DOWN', _MRef, process, Pid, Reason} -> - check_shutdown_reason(shutdown, Reason) + {'DOWN', _MRef, process, Pid, shutdown} -> + ok; + {'DOWN', _MRef, process, Pid, OtherReason} -> + {error, OtherReason} after Time -> exit(Pid, kill), %% Force termination. receive @@ -715,14 +727,11 @@ monitor_child(Pid) -> receive %% If the child dies before the unlik we must empty %% the mail-box of the 'EXIT'-message and the 'DOWN'-message. - {'EXIT', Pid, Reason} -> - receive - {'DOWN', _, process, Pid, _} -> - case Reason of - normal -> ok; - _ -> {error, Reason} - end - end + {'EXIT', Pid, Reason} -> + receive + {'DOWN', _, process, Pid, _} -> + {error, Reason} + end after 0 -> %% If a naughty child did unlink and the child dies before %% monitor the result will be that shutdown/2 receives a @@ -732,11 +741,8 @@ monitor_child(Pid) -> %% that will be handled in shutdown/2. ok end. - -check_shutdown_reason(Reason, Reason) -> ok; -check_shutdown_reason(_ , normal) -> ok; -check_shutdown_reason(Reason, _) -> {error, Reason}. - + + %%----------------------------------------------------------------- %% Child/State manipulating functions. %%----------------------------------------------------------------- |
