From 33bf9857c1d1faa77109c20a95fa241d8e1cd276 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Mon, 20 Sep 2010 23:32:27 +0100 Subject: Only emit stats on shutdown if they're enabled... --- src/rabbit_amqqueue_process.erl | 2 +- src/rabbit_channel.erl | 4 +++- src/rabbit_event.erl | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 8f4c200d..c80df02c 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -926,6 +926,6 @@ handle_pre_hibernate(State = #q{backing_queue = BQ, DesiredDuration = rabbit_memory_monitor:report_ram_duration(self(), infinity), BQS2 = BQ:set_ram_duration_target(DesiredDuration, BQS1), - emit_stats(State), + rabbit_event:if_enabled(StatsTimer, fun () -> emit_stats(State) end), State1 = State#q{stats_timer = rabbit_event:stop_stats_timer(StatsTimer)}, {hibernate, stop_rate_timer(State1#q{backing_queue_state = BQS2})}. diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index bd52a40c..a199a02e 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -251,7 +251,9 @@ handle_info({'DOWN', _MRef, process, QPid, _Reason}, State) -> handle_pre_hibernate(State = #ch{stats_timer = StatsTimer}) -> ok = clear_permission_cache(), - internal_emit_stats(State), + rabbit_event:if_enabled(StatsTimer, fun () -> + internal_emit_stats(State) + end), State1 = State#ch{stats_timer = rabbit_event:stop_stats_timer(StatsTimer)}, {hibernate, State1}. diff --git a/src/rabbit_event.erl b/src/rabbit_event.erl index 3ef02517..ff323a21 100644 --- a/src/rabbit_event.erl +++ b/src/rabbit_event.erl @@ -90,18 +90,18 @@ start_link() -> %% On startup: %% Timer = init_stats_timer() %% notify(created event) -%% maybe(internal_emit_stats) - so we immediately send something +%% if_enabled(internal_emit_stats) - so we immediately send something %% %% On wakeup: %% ensure_stats_timer(Timer, emit_stats) %% (Note we can't emit stats immediately, the timer may have fired 1ms ago.) %% %% emit_stats: -%% internal_emit_stats +%% if_enabled(internal_emit_stats) %% reset_stats_timer(Timer) - just bookkeeping %% %% Pre-hibernation: -%% internal_emit_stats +%% if_enabled(internal_emit_stats) %% stop_stats_timer(Timer) %% %% internal_emit_stats: -- cgit v1.2.1