diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-09-09 16:03:47 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-09-09 16:03:47 +0100 |
commit | 0c5e442e2c02157d2721e04c506ff16812cf30af (patch) | |
tree | 207500df79b43d65650ecea2acae91d7669a5f6c | |
parent | 1c155a643f5985b0e3a34cc3b1edb9da087b8a9b (diff) | |
download | rabbitmq-server-0c5e442e2c02157d2721e04c506ff16812cf30af.tar.gz |
Rename slightly and improve comments.
-rw-r--r-- | src/rabbit_amqqueue_process.erl | 6 | ||||
-rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 4 | ||||
-rw-r--r-- | src/rabbit_prequeue.erl | 20 |
3 files changed, 16 insertions, 14 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 02f1fa16..537eaff5 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -26,7 +26,7 @@ -export([info_keys/0]). --export([init_declared/3, init_with_backing_queue_state/7]). +-export([become/3, init_with_backing_queue_state/7]). -export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2, handle_info/2, handle_pre_hibernate/1, prioritise_call/4, @@ -108,8 +108,8 @@ statistics_keys() -> ?STATISTICS_KEYS ++ rabbit_backing_queue:info_keys(). init(_) -> exit(cannot_be_called_directly). %% We have just been declared or recovered -init_declared(Recover, From, Q = #amqqueue{name = QName, - exclusive_owner = Owner}) -> +become(Recover, From, Q = #amqqueue{name = QName, + exclusive_owner = Owner}) -> process_flag(trap_exit, true), ?store_proc_name(QName), State = init_state(Q), diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index 0c9e6c21..c2bf1b89 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -24,7 +24,7 @@ %% All instructions from the GM group must be processed in the order %% in which they're received. --export([set_maximum_since_use/2, info/1, init_slave/1, await/1]). +-export([set_maximum_since_use/2, info/1, become/1, await/1]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3, handle_pre_hibernate/1, prioritise_call/4, @@ -80,7 +80,7 @@ await(SPid) -> gen_server2:call(SPid, await, infinity). init(_) -> exit(cannot_be_called_directly). -init_slave(Q = #amqqueue{name = QName}) -> +become(Q = #amqqueue{name = QName}) -> ?store_proc_name(QName), %% We join the GM group before we add ourselves to the amqqueue %% record. As a result: 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). |