diff options
author | Matthias Radestock <matthias@lshift.net> | 2010-05-07 17:34:12 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@lshift.net> | 2010-05-07 17:34:12 +0100 |
commit | 7b644dfe335fa15f2c32772631fc6ecad41824f2 (patch) | |
tree | 561c5c09c13f181bc9f6f37291958c1306f48739 | |
parent | a3201c48d51dbfc7783db567ab4ec7a20a1d3ed4 (diff) | |
download | rabbitmq-server-bug22697.tar.gz |
get rid of now redundant 'sync' call handlerbug22697
and some cosmetic changes
-rw-r--r-- | src/rabbit_amqqueue.erl | 4 | ||||
-rw-r--r-- | src/rabbit_amqqueue_process.erl | 46 |
2 files changed, 23 insertions, 27 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 2af67736..7b88c45d 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -146,9 +146,7 @@ find_durable_queues() -> recover_durable_queues(DurableQueues) -> Qs = [start_queue_process(Q) || Q <- DurableQueues], - %% Issue inits to *all* the queues so that they all init at the same time - [Q || Q <- Qs, - gen_server2:call(Q#amqqueue.pid, {init, true}) == Q]. + [Q || Q <- Qs, gen_server2:call(Q#amqqueue.pid, {init, true}) == Q]. declare(QueueName, Durable, AutoDelete, Args) -> Q = start_queue_process(#amqqueue{name = QueueName, diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index fb4c0860..f12e1b70 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -519,8 +519,27 @@ i(Item, _) -> %--------------------------------------------------------------------------- -handle_call(sync, _From, State) -> - reply(ok, State); +handle_call({init, Recover}, From, + State = #q{q = Q = #amqqueue{name = QName, durable = IsDurable}, + backing_queue = BQ, backing_queue_state = undefined}) -> + %% TODO: If we're exclusively owned && our owner isn't alive && + %% Recover then we should BQ:init and then {stop, normal, + %% not_found, State}, relying on terminate to delete the queue. + case rabbit_amqqueue:internal_declare(Q, Recover) of + not_found -> + {stop, normal, not_found, State}; + Q -> + gen_server2:reply(From, Q), + ok = file_handle_cache:register_callback( + rabbit_amqqueue, set_maximum_since_use, [self()]), + ok = rabbit_memory_monitor:register( + self(), + {rabbit_amqqueue, set_ram_duration_target, [self()]}), + noreply(State#q{backing_queue_state = + BQ:init(QName, IsDurable, Recover)}); + Q1 -> + {stop, normal, Q1, State} + end; handle_call(info, _From, State) -> reply(infos(?INFO_KEYS, State), State); @@ -718,28 +737,7 @@ handle_call({claim_queue, ReaderPid}, _From, end; handle_call({maybe_run_queue_via_backing_queue, Fun}, _From, State) -> - reply(ok, maybe_run_queue_via_backing_queue(Fun, State)); - -handle_call({init, Recover}, From, - State = #q{q = Q = #amqqueue{name = QName, durable = IsDurable}, - backing_queue = BQ, backing_queue_state = undefined}) -> - %% TODO: If we're exclusively owned && our owner isn't alive && - %% Recover then we should BQ:init and then {stop, normal, - %% not_found, State}, relying on terminate to delete the queue. - case rabbit_amqqueue:internal_declare(Q, Recover) of - not_found -> - {stop, normal, not_found, State}; - Q -> - gen_server2:reply(From, Q), - ok = file_handle_cache:register_callback( - rabbit_amqqueue, set_maximum_since_use, [self()]), - ok = rabbit_memory_monitor:register( - self(), {rabbit_amqqueue, set_ram_duration_target, [self()]}), - noreply(State#q{backing_queue_state = - BQ:init(QName, IsDurable, Recover)}); - Q1 -> - {stop, normal, Q1, State} - end. + reply(ok, maybe_run_queue_via_backing_queue(Fun, State)). handle_cast({deliver, Txn, Message, ChPid}, State) -> %% Asynchronous, non-"mandatory", non-"immediate" deliver mode. |