summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-08-10 12:53:40 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2010-08-10 12:53:40 +0100
commit0a81f9e6fb0c02073ccfea530edaf4cd2081ff40 (patch)
tree0daaf3517b3fc5bf0324954447f9f35263e8a7bb /src
parent4cf09750c87c04aacedc24609b21fe2eaf3f73fb (diff)
downloadrabbitmq-server-git-0a81f9e6fb0c02073ccfea530edaf4cd2081ff40.tar.gz
Prevent supervisor2 from getting upset if a child has already vanished normally whilst the supervisor is trying to stop it
Diffstat (limited to 'src')
-rw-r--r--src/supervisor2.erl29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/supervisor2.erl b/src/supervisor2.erl
index 8d0f5f4b19..b1b3760b4a 100644
--- a/src/supervisor2.erl
+++ b/src/supervisor2.erl
@@ -676,10 +676,13 @@ shutdown(Pid, brutal_kill) ->
ok ->
exit(Pid, kill),
receive
- {'DOWN', _MRef, process, Pid, killed} ->
- ok;
{'DOWN', _MRef, process, Pid, OtherReason} ->
- {error, OtherReason}
+ case OtherReason of
+ killed -> ok;
+ normal -> ok;
+ noproc -> ok;
+ _ -> {error, OtherReason}
+ end
end;
{error, Reason} ->
{error, Reason}
@@ -691,10 +694,13 @@ shutdown(Pid, Time) ->
ok ->
exit(Pid, shutdown), %% Try to shutdown gracefully
receive
- {'DOWN', _MRef, process, Pid, shutdown} ->
- ok;
{'DOWN', _MRef, process, Pid, OtherReason} ->
- {error, OtherReason}
+ case OtherReason of
+ shutdown -> ok;
+ normal -> ok;
+ noproc -> ok;
+ _ -> {error, OtherReason}
+ end
after Time ->
exit(Pid, kill), %% Force termination.
receive
@@ -720,10 +726,13 @@ monitor_child(Pid) ->
%% 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, _} ->
- {error, Reason}
- end
+ case Reason of
+ normal -> ok;
+ _ -> receive
+ {'DOWN', _, process, Pid, _} ->
+ {error, Reason}
+ end
+ end
after 0 ->
%% If a naughty child did unlink and the child dies before
%% monitor the result will be that shutdown/2 receives a