summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2012-10-16 12:12:31 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2012-10-16 12:12:31 +0100
commite352e4c34c92ff3be1cb6beb3692b9a31e194ede (patch)
treef92675d28e2ce9e6eab726627901c53790d110e6
parente5f8663bb6b20f7ff515ee6bf021e9905f2629ef (diff)
downloadrabbitmq-server-e352e4c34c92ff3be1cb6beb3692b9a31e194ede.tar.gz
refactor: slightly more sensible signature for add_slave
-rw-r--r--src/rabbit_mirror_queue_slave.erl14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl
index 7d05bcc0..6caf135b 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.