diff options
| author | Emile Joubert <emile@rabbitmq.com> | 2011-10-17 11:58:23 +0100 |
|---|---|---|
| committer | Emile Joubert <emile@rabbitmq.com> | 2011-10-17 11:58:23 +0100 |
| commit | 6f8aefa84ee409f1ac9590d79cf810fefa7d7479 (patch) | |
| tree | 0ad7b9370768104a563015d406201c26ad76ebfc /src | |
| parent | ea3c15e3d5e2006bdfc6d13e7a5b07860e828085 (diff) | |
| download | rabbitmq-server-git-6f8aefa84ee409f1ac9590d79cf810fefa7d7479.tar.gz | |
Better supervisor2 shutdown handling
Diffstat (limited to 'src')
| -rw-r--r-- | src/supervisor2.erl | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl index efbd809b37..0f8e9d735c 100644 --- a/src/supervisor2.erl +++ b/src/supervisor2.erl @@ -664,27 +664,27 @@ terminate_simple_children(Child, Dynamics, SupName) -> lists:foldl( fun (_Pid, {Replies, Timedout}) -> receive - {'DOWN', _, process, Pid, Reason} + {'DOWN', _MRef, process, Pid, Reason} when Child#child.shutdown == brutal_kill andalso Reason == killed andalso Timedout == false orelse - Reason == shutdown -> + Reason == shutdown andalso Timedout == false -> {dict:append(Pid, ok, Replies), Timedout}; - {'DOWN', _, process, Pid, Reason} -> + {'DOWN', _MRef, process, Pid, Reason} -> {dict:append(Pid, {error, Reason}, Replies), Timedout}; {'EXIT', Pid, Reason} -> - receive {'DOWN', _, process, Pid, _} -> + receive {'DOWN', _MRef, process, Pid, _} -> {dict:append(Pid, {error, Reason}, Replies), Timedout} end after Timeout -> case Timedout of false -> lists:foldl(fun (Pid, ok) -> exit(Pid, kill) end, - Pids -- dict:fetch_keys(Replies)), - receive {'DOWN', _, process, Pid, Reason} -> - {dict:append(Pid, {error, Reason}, Replies), - true} - end; + Pids -- dict:fetch_keys(Replies)); true -> ok %% actually not ok - we await replies to kill %% signals after 2 timeouts + end, + receive {'DOWN', _, process, Pid, Reason} -> + {dict:append(Pid, {error, Reason}, Replies), + true} end end end, {dict:new(), false}, Pids), @@ -694,14 +694,14 @@ terminate_simple_children(Child, Dynamics, SupName) -> _ -> false end, ReportAcc = fun (NormalErrorFun) -> - fun (Pid, ok, ok) -> - ok; - (Pid, {error, normal}, ok) -> + fun (Pid, ok, Acc) -> + Acc; + (Pid, {error, normal}, Acc) -> NormalErrorFun(Pid), - ok; - (Pid, {error, Reason}, ok) -> + Acc; + (Pid, {error, Reason}, Acc) -> ReportError(Reason, Child#child{pid = Pid}), - ok + Acc end end, dict:fold(case RestartPerm of @@ -710,7 +710,7 @@ terminate_simple_children(Child, Dynamics, SupName) -> ReportError(normal, Child#child{pid = Pid}) end); false -> - ReportAcc(fun (_Pid) -> ok end) + ReportAcc(fun rabbit_misc:const_ok/0) end, ok, Replies), ok. |
