diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2012-11-28 15:33:48 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-11-28 15:33:48 +0000 |
| commit | 423fbb589dc4fbf0cb9be363a15de8f2bfbf57b1 (patch) | |
| tree | 0250fd673c119009a95a9ccd7b0b77c99b830bd8 | |
| parent | 5e106df68b867ec9723565b2347fab9b5c69664d (diff) | |
| download | rabbitmq-server-git-423fbb589dc4fbf0cb9be363a15de8f2bfbf57b1.tar.gz | |
cosmetic
| -rw-r--r-- | src/rabbit_mirror_queue_master.erl | 28 | ||||
| -rw-r--r-- | src/rabbit_mirror_queue_sync.erl | 5 |
2 files changed, 14 insertions, 19 deletions
diff --git a/src/rabbit_mirror_queue_master.erl b/src/rabbit_mirror_queue_master.erl index e8734a8cbf..0e8748fd3e 100644 --- a/src/rabbit_mirror_queue_master.erl +++ b/src/rabbit_mirror_queue_master.erl @@ -127,27 +127,27 @@ stop_mirroring(State = #state { coordinator = CPid, stop_all_slaves(shutdown, State), {BQ, BQS}. -sync_mirrors(State = #state{name = Name}) -> +sync_mirrors(State = #state{name = QName}) -> {ok, #amqqueue{slave_pids = SPids, sync_slave_pids = SSPids}} = - rabbit_amqqueue:lookup(Name), + rabbit_amqqueue:lookup(QName), sync_mirrors(SPids -- SSPids, State). -sync_mirrors([], State = #state{name = Name}) -> +sync_mirrors([], State = #state{name = QName}) -> rabbit_log:info("Synchronising ~s: nothing to do~n", - [rabbit_misc:rs(Name)]), + [rabbit_misc:rs(QName)]), State; -sync_mirrors(SPids, State = #state { name = Name, +sync_mirrors(SPids, State = #state { name = QName, gm = GM, backing_queue = BQ, backing_queue_state = BQS }) -> rabbit_log:info("Synchronising ~s with slaves ~p: ~p messages to do~n", - [rabbit_misc:rs(Name), SPids, BQ:len(BQS)]), + [rabbit_misc:rs(QName), SPids, BQ:len(BQS)]), Ref = make_ref(), Syncer = rabbit_mirror_queue_sync:master_prepare(Ref, SPids), gm:broadcast(GM, {sync_start, Ref, Syncer, SPids}), - BQS1 = rabbit_mirror_queue_sync:master_go(Syncer, Ref, Name, BQ, BQS), + BQS1 = rabbit_mirror_queue_sync:master_go(Syncer, Ref, QName, BQ, BQS), rabbit_log:info("Synchronising ~s: complete~n", - [rabbit_misc:rs(Name)]), + [rabbit_misc:rs(QName)]), State#state{backing_queue_state = BQS1}. terminate({shutdown, dropped} = Reason, @@ -173,11 +173,9 @@ 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 = Name, - gm = GM}) -> - {ok, #amqqueue{slave_pids = SPids}} = rabbit_amqqueue:lookup(Name), - Slaves = [Pid || Pid <- SPids], - MRefs = [erlang:monitor(process, S) || S <- Slaves], +stop_all_slaves(Reason, #state{name = QName, gm = GM}) -> + {ok, #amqqueue{slave_pids = SPids}} = rabbit_amqqueue:lookup(QName), + MRefs = [erlang:monitor(process, SPid) || SPid <- 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 @@ -185,11 +183,11 @@ stop_all_slaves(Reason, #state{name = Name, %% have stopped listening ourselves. So manually clean up. rabbit_misc:execute_mnesia_transaction( fun () -> - [Q] = mnesia:read({rabbit_queue, Name}), + [Q] = mnesia:read({rabbit_queue, QName}), rabbit_mirror_queue_misc:store_updated_slaves( Q #amqqueue { gm_pids = [], slave_pids = [] }) end), - ok = gm:forget_group(Name). + ok = gm:forget_group(QName). purge(State = #state { gm = GM, backing_queue = BQ, diff --git a/src/rabbit_mirror_queue_sync.erl b/src/rabbit_mirror_queue_sync.erl index 0fd50e40ca..b9fb6cb665 100644 --- a/src/rabbit_mirror_queue_sync.erl +++ b/src/rabbit_mirror_queue_sync.erl @@ -83,10 +83,7 @@ master_send({Syncer, Ref, Name}, I, Last, Msg, MsgProps) -> %% Syncer syncer(Ref, MPid, SPids) -> - SPidsMRefs = [begin - MRef = erlang:monitor(process, SPid), - {SPid, MRef} - end || SPid <- SPids], + SPidsMRefs = [{SPid, erlang:monitor(process, SPid)} || SPid <- SPids], %% We wait for a reply from the slaves so that we know they are in %% a receive block and will thus receive messages we send to them %% *without* those messages ending up in their gen_server2 pqueue. |
