summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2012-08-30 13:56:59 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2012-08-30 13:56:59 +0100
commit6934fac0e30d9d9c4f179c38598aaa78a76dced4 (patch)
treea9f1a6a4e8d73374215aafd387d763b2d702952a
parent6389be116625872fa6f8bde8d071ac2ccd06e81f (diff)
downloadrabbitmq-server-6934fac0e30d9d9c4f179c38598aaa78a76dced4.tar.gz
refactor
and always prefer the EXIT reason
-rw-r--r--src/supervisor2.erl28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl
index dba9d4b5..89a8fd92 100644
--- a/src/supervisor2.erl
+++ b/src/supervisor2.erl
@@ -816,36 +816,30 @@ terminate_simple_children(Child, Dynamics, SupName) ->
{Replies, Timedout} =
lists:foldl(
fun (_Pid, {Replies, Timedout}) ->
- {Pid, Reply, Timedout1} =
+ {Pid1, Reason1, Timedout1} =
receive
TimeoutMsg ->
Remaining = Pids -- [P || {P, _} <- Replies],
[exit(P, kill) || P <- Remaining],
- receive {'DOWN', _MRef, process, Pid, Reason} ->
- Res = child_res(Child, Reason, Timedout),
- {Pid, Res, true}
+ receive
+ {'DOWN', _MRef, process, Pid, Reason} ->
+ {Pid, Reason, true}
end;
{'DOWN', _MRef, process, Pid, Reason} ->
- Res = child_res(Child, Reason, Timedout),
- {Pid, Res, Timedout}
+ {Pid, Reason, Timedout}
end,
- {[{Pid, Reply} | Replies], Timedout1}
+ {[{Pid1, child_res(Child, Reason1, Timedout1)} | Replies],
+ Timedout1}
end, {[], false}, Pids),
timeout_stop(Child, TRef, TimeoutMsg, Timedout),
ReportError = shutdown_error_reporter(SupName),
Report = fun(_, ok) -> ok;
(Pid, {error, R}) -> ReportError(R, Child#child{pid = Pid})
end,
- [begin
- receive
- {'EXIT', Pid, Reason} ->
- case Reply of
- {error, noproc} -> Report(Pid, Reason);
- _ -> Report(Pid, Reply)
- end
- after
- 0 -> Report(Pid, Reply)
- end
+ [receive
+ {'EXIT', Pid, Reason} -> Report(Pid, Reason)
+ after
+ 0 -> Report(Pid, Reply)
end || {Pid, Reply} <- Replies],
ok.