summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@lshift.net>2010-04-26 19:00:00 +0100
committerMatthias Radestock <matthias@lshift.net>2010-04-26 19:00:00 +0100
commit04df18da4a906194530abdb6d55e5571257e5e3d (patch)
tree64fdcb67464babb0c9e729f2f8012ad7cf2d748e /src
parentaf5be2c30446e6fb83c83096b7ca6d929f103c5e (diff)
downloadrabbitmq-server-git-04df18da4a906194530abdb6d55e5571257e5e3d.tar.gz
guard against operating on uninitialised backing_queue_state
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_amqqueue_process.erl10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index 12429d2548..b85bcdcb63 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -106,8 +106,6 @@ init([Q]) ->
process_flag(trap_exit, true),
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()]}),
{ok, BQ} = application:get_env(backing_queue_module),
{ok, #q{q = Q,
@@ -139,10 +137,10 @@ code_change(_OldVsn, State, _Extra) ->
terminate_shutdown(Fun, State = #q{backing_queue = BQ,
backing_queue_state = BQS}) ->
- ok = rabbit_memory_monitor:deregister(self()),
case BQS of
undefined -> State;
- _ -> BQS1 = lists:foldl(
+ _ -> ok = rabbit_memory_monitor:deregister(self()),
+ BQS1 = lists:foldl(
fun (#cr{txn = none}, BQSN) ->
BQSN;
(#cr{txn = Txn}, BQSN) ->
@@ -726,6 +724,8 @@ handle_call({maybe_run_queue_via_backing_queue, Fun}, _From, State) ->
handle_cast(init_backing_queue,
State = #q{q = #amqqueue{name = QName, durable = IsDurable},
backing_queue = BQ, backing_queue_state = undefined}) ->
+ ok = rabbit_memory_monitor:register(
+ self(), {rabbit_amqqueue, set_ram_duration_target, [self()]}),
noreply(State#q{backing_queue_state = BQ:init(QName, IsDurable)});
handle_cast(init_backing_queue, State) ->
@@ -850,6 +850,8 @@ handle_info(Info, State) ->
?LOGDEBUG("Info in queue: ~p~n", [Info]),
{stop, {unhandled_info, Info}, State}.
+handle_pre_hibernate(State = #q{backing_queue_state = undefined}) ->
+ {hibernate, State};
handle_pre_hibernate(State = #q{backing_queue = BQ,
backing_queue_state = BQS}) ->
BQS1 = BQ:handle_pre_hibernate(BQS),