diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-08-10 18:03:54 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-08-10 18:03:54 +0100 |
| commit | 96c02054ddc0b3ba02a9a7b27692a6f58465af67 (patch) | |
| tree | a11931161eeb2dde59580156107238b93c216946 /src | |
| parent | 572816800c67df388d66463a23bf96703ca53df0 (diff) | |
| download | rabbitmq-server-git-96c02054ddc0b3ba02a9a7b27692a6f58465af67.tar.gz | |
Fix stop raciness.
Diffstat (limited to 'src')
| -rw-r--r-- | src/mirrored_supervisor.erl | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mirrored_supervisor.erl b/src/mirrored_supervisor.erl index 9bc350b2e4..5e7ce63906 100644 --- a/src/mirrored_supervisor.erl +++ b/src/mirrored_supervisor.erl @@ -444,10 +444,17 @@ start(Delegate, ChildSpec) -> apply(?SUPERVISOR, start_child, [Delegate, ChildSpec]). stop(Delegate, Id) -> + case mnesia:transaction(fun() -> check_stop(Delegate, Id) end) of + {atomic, deleted} -> apply(?SUPERVISOR, delete_child, [Delegate, Id]); + {atomic, running} -> {error, running}; + {aborted, E} -> {error, E} + end. + +check_stop(Delegate, Id) -> case child(Delegate, Id) of - undefined -> {atomic, ok} = mnesia:transaction(fun() -> delete(Id) end), - apply(?SUPERVISOR, delete_child, [Delegate, Id]); - _ -> {error, running} + undefined -> delete(Id), + deleted; + _ -> running end. id({Id, _, _, _, _, _}) -> Id. |
