summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-12-01 18:28:26 +0000
committerSimon MacMullen <simon@rabbitmq.com>2011-12-01 18:28:26 +0000
commit3f19dee21e472846644b537309714933127bbb39 (patch)
treed1277ab2ab0912cbe4ad25ee8236b73e24ee2277
parent83ebef63bd11e89bd8ee4e558da2f54c27f6a03b (diff)
downloadrabbitmq-server-3f19dee21e472846644b537309714933127bbb39.tar.gz
We need to distinguish between the already_started we make get back from the real supervisor (which we need to treat as a real error at init) and the one we cons up ourselves (which we can ignore at init since in general all the mirrored sups in a group will have the same childspecs). But we treat them both as errors for start_child though.
-rw-r--r--src/mirrored_supervisor.erl10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mirrored_supervisor.erl b/src/mirrored_supervisor.erl
index e5ea648d..02a2f378 100644
--- a/src/mirrored_supervisor.erl
+++ b/src/mirrored_supervisor.erl
@@ -357,7 +357,11 @@ handle_call({init, Overall}, _From,
handle_call({start_child, ChildSpec}, _From,
State = #state{delegate = Delegate,
group = Group}) ->
- {reply, maybe_start(Group, Delegate, ChildSpec), State};
+ {reply, case maybe_start(Group, Delegate, ChildSpec) of
+ already_in_mnesia -> {error, already_present};
+ {already_in_mnesia, Pid} -> {error, {already_started, Pid}};
+ Else -> Else
+ end, State};
handle_call({delete_child, Id}, _From, State = #state{delegate = Delegate,
group = Group}) ->
@@ -436,8 +440,8 @@ maybe_start(Group, Delegate, ChildSpec) ->
check_start(Group, Delegate, ChildSpec)
end) of
{atomic, start} -> start(Delegate, ChildSpec);
- {atomic, undefined} -> {error, already_present};
- {atomic, Pid} -> {error, {already_started, Pid}};
+ {atomic, undefined} -> already_in_mnesia;
+ {atomic, Pid} -> {already_in_mnesia, Pid};
%% If we are torn down while in the transaction...
{aborted, E} -> {error, E}
end.