diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2012-10-16 12:12:31 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-10-16 12:12:31 +0100 |
| commit | 811f35ceeac31ab66e8c57bb0962b97c2209896c (patch) | |
| tree | f92675d28e2ce9e6eab726627901c53790d110e6 | |
| parent | 33022ae6dfefacfac492ef2087a31e1178fd4b40 (diff) | |
| download | rabbitmq-server-git-811f35ceeac31ab66e8c57bb0962b97c2209896c.tar.gz | |
refactor: slightly more sensible signature for add_slave
| -rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index 7d05bcc0e9..6caf135b3c 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -145,10 +145,10 @@ init(#amqqueue { name = QueueName } = Q) -> end. init_it(Self, Node, QueueName) -> - [Q1 = #amqqueue { pid = QPid, slave_pids = SPids }] = - mnesia:read({rabbit_queue, QueueName}), + [Q = #amqqueue { pid = QPid, slave_pids = SPids }] = + mnesia:read({rabbit_queue, QueueName}), case [Pid || Pid <- [QPid | SPids], node(Pid) =:= Node] of - [] -> add_slave(Q1, Self, SPids), + [] -> add_slave(Q, Self), {new, QPid}; [QPid] -> case rabbit_misc:is_process_alive(QPid) of true -> duplicate_live_master; @@ -156,15 +156,17 @@ init_it(Self, Node, QueueName) -> end; [SPid] -> case rabbit_misc:is_process_alive(SPid) of true -> existing; - false -> add_slave(Q1, Self, SPids -- [SPid]), + false -> Q1 = Q#amqqueue { slave_pids = SPids -- [SPid] }, + add_slave(Q1, Self), {new, QPid} end end. %% Add to the end, so they are in descending order of age, see %% rabbit_mirror_queue_misc:promote_slave/1 -add_slave(Q, New, SPids) -> rabbit_mirror_queue_misc:store_updated_slaves( - Q#amqqueue{slave_pids = SPids ++ [New]}). +add_slave(Q = #amqqueue { slave_pids = SPids }, New) -> + rabbit_mirror_queue_misc:store_updated_slaves( + Q#amqqueue{slave_pids = SPids ++ [New]}). handle_call({deliver, Delivery, true}, From, State) -> %% Synchronous, "mandatory" deliver mode. |
