summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-04-10 17:23:56 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-04-10 17:23:56 +0100
commit132008e2f469c9eb89ba16c307909e75ce5593cc (patch)
treeecfbad7cdc56dfcd62ec7b2282cfa1f73393a55c
parenteb2f22387ec2b4cf76e89fac8a5f8a146d15d032 (diff)
downloadrabbitmq-server-132008e2f469c9eb89ba16c307909e75ce5593cc.tar.gz
Monitor and wait for 'DOWN' from our own GM as well as the slaves, to make sure our GM does not try to update group info after we have called forget_group/1. Also ensure we unlink from the coordinator when shutting down as well as when stopping mirroring, not strictly necessary but clearer.
-rw-r--r--src/rabbit_mirror_queue_master.erl11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/rabbit_mirror_queue_master.erl b/src/rabbit_mirror_queue_master.erl
index 4bb923c4..7a08bee4 100644
--- a/src/rabbit_mirror_queue_master.erl
+++ b/src/rabbit_mirror_queue_master.erl
@@ -126,10 +126,8 @@ init_with_existing_bq(Q = #amqqueue{name = QName}, BQ, BQS) ->
confirmed = [],
known_senders = sets:new() }.
-stop_mirroring(State = #state { coordinator = CPid,
- backing_queue = BQ,
+stop_mirroring(State = #state { backing_queue = BQ,
backing_queue_state = BQS }) ->
- unlink(CPid),
stop_all_slaves(shutdown, State),
{BQ, BQS}.
@@ -181,9 +179,12 @@ delete_and_terminate(Reason, State = #state { backing_queue = BQ,
stop_all_slaves(Reason, State),
State#state{backing_queue_state = BQ:delete_and_terminate(Reason, BQS)}.
-stop_all_slaves(Reason, #state{name = QName, gm = GM}) ->
+stop_all_slaves(Reason, #state{name = QName,
+ gm = GM,
+ coordinator = CPid}) ->
{ok, #amqqueue{slave_pids = SPids}} = rabbit_amqqueue:lookup(QName),
- MRefs = [erlang:monitor(process, SPid) || SPid <- SPids],
+ unlink(CPid),
+ MRefs = [erlang:monitor(process, Pid) || Pid <- [GM | SPids]],
ok = gm:broadcast(GM, {delete_and_terminate, Reason}),
[receive {'DOWN', MRef, process, _Pid, _Info} -> ok end || MRef <- MRefs],
%% Normally when we remove a slave another slave or master will