diff options
| -rw-r--r-- | src/rabbit_mirror_queue_master.erl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/rabbit_mirror_queue_master.erl b/src/rabbit_mirror_queue_master.erl index 4bb923c479..7a08bee4b1 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 |
