diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2012-08-30 13:56:59 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-08-30 13:56:59 +0100 |
| commit | fdd68a9c27e2ba6e44f86b3c38c88c77d23b1e7a (patch) | |
| tree | a9f1a6a4e8d73374215aafd387d763b2d702952a | |
| parent | 34560411a1566f7238c29d6681a6c4b77d3cf03f (diff) | |
| download | rabbitmq-server-git-fdd68a9c27e2ba6e44f86b3c38c88c77d23b1e7a.tar.gz | |
refactor
and always prefer the EXIT reason
| -rw-r--r-- | src/supervisor2.erl | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl index dba9d4b51f..89a8fd9213 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. |
