summaryrefslogtreecommitdiff
path: root/src/rabbit_prequeue.erl
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-09-09 16:03:47 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-09-09 16:03:47 +0100
commit0c5e442e2c02157d2721e04c506ff16812cf30af (patch)
tree207500df79b43d65650ecea2acae91d7669a5f6c /src/rabbit_prequeue.erl
parent1c155a643f5985b0e3a34cc3b1edb9da087b8a9b (diff)
downloadrabbitmq-server-0c5e442e2c02157d2721e04c506ff16812cf30af.tar.gz
Rename slightly and improve comments.
Diffstat (limited to 'src/rabbit_prequeue.erl')
-rw-r--r--src/rabbit_prequeue.erl20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/rabbit_prequeue.erl b/src/rabbit_prequeue.erl
index fd20e926..cfe21494 100644
--- a/src/rabbit_prequeue.erl
+++ b/src/rabbit_prequeue.erl
@@ -92,13 +92,14 @@ init_declared(Q = #amqqueue{name = QueueName}) ->
[ExistingQ] -> {existing, ExistingQ}
end
end),
- %% We have just been declared. Block waiting for an init
- %% call so that we don't respond to any other message first
+ %% We have just been declared. Block waiting for an init call so
+ %% that we can let the declarer know whether we actually started
+ %% something.
receive {'$gen_call', From, {init, new}} ->
case Decl of
{new, Fun} ->
Q1 = Fun(),
- rabbit_amqqueue_process:init_declared(new,From, Q1);
+ rabbit_amqqueue_process:become(new, From, Q1);
{absent, _, _} ->
gen_server2:reply(From, Decl),
{stop, normal, Q};
@@ -111,9 +112,10 @@ init_declared(Q = #amqqueue{name = QueueName}) ->
init_recovery(Q) ->
rabbit_misc:execute_mnesia_transaction(
fun () -> ok = rabbit_amqqueue:store_queue(Q) end),
- %% Again block waiting for an init call.
+ %% This time we have an init call to ensure the recovery terms do
+ %% not sit in the supervisor forever.
receive {'$gen_call', From, {init, Terms}} ->
- rabbit_amqqueue_process:init_declared(Terms, From, Q)
+ rabbit_amqqueue_process:become(Terms, From, Q)
end.
init_slave(Q) ->
@@ -126,11 +128,11 @@ init_restart(#amqqueue{name = QueueName}) ->
Slaves = [SPid || SPid <- SPids, rabbit_misc:is_process_alive(SPid)],
case rabbit_misc:is_process_alive(QPid) of
true -> false = Local, %% assertion
- rabbit_mirror_queue_slave:init_slave(Q); %% [1]
+ rabbit_mirror_queue_slave:become(Q); %% [1]
false -> case Local andalso Slaves =:= [] of
- true -> crash_restart(Q); %% [2]
+ true -> crash_restart(Q); %% [2]
false -> timer:sleep(25),
- init_restart(Q) %% [3]
+ init_restart(Q) %% [3]
end
end.
%% [1] There is a master on another node. Regardless of whether we
@@ -148,5 +150,5 @@ crash_restart(Q = #amqqueue{name = QueueName}) ->
Self = self(),
rabbit_misc:execute_mnesia_transaction(
fun () -> ok = rabbit_amqqueue:store_queue(Q#amqqueue{pid = Self}) end),
- rabbit_amqqueue_process:init_declared(
+ rabbit_amqqueue_process:become(
{no_barrier, non_clean_shutdown}, none, Q).