summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-08-02 11:41:23 +0100
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-08-02 11:41:23 +0100
commitc6b1df765ff968a0b5e0686fef143351143820ff (patch)
treeb3c54036de613bdb5c909082cb7c19e6c6fd824d
parent5d2fba42902b1a09eb911dc77fd1a0b5c7c8f969 (diff)
downloadrabbitmq-server-c6b1df765ff968a0b5e0686fef143351143820ff.tar.gz
some more refactoring
-rw-r--r--src/rabbit_amqqueue_process.erl5
-rw-r--r--src/rabbit_channel.erl12
-rw-r--r--src/rabbit_event.erl2
-rw-r--r--src/rabbit_misc.erl8
-rw-r--r--src/rabbit_msg_store.erl2
-rw-r--r--src/rabbit_tests.erl2
6 files changed, 18 insertions, 13 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index c7b9eaab..403c39fc 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -275,13 +275,13 @@ stop_rate_timer(State = #q{rate_timer_ref = undefined}) ->
stop_rate_timer(State = #q{rate_timer_ref = just_measured}) ->
State#q{rate_timer_ref = undefined};
stop_rate_timer(State = #q{rate_timer_ref = TRef}) ->
- erlang:cancel_timer(TRef),
+ rabbit_misc:cancel_timer(TRef),
State#q{rate_timer_ref = undefined}.
stop_expiry_timer(State = #q{expiry_timer_ref = undefined}) ->
State;
stop_expiry_timer(State = #q{expiry_timer_ref = TRef}) ->
- erlang:cancel_timer(TRef),
+ rabbit_misc:cancel_timer(TRef),
State#q{expiry_timer_ref = undefined}.
%% We wish to expire only when there are no consumers *and* the expiry
@@ -790,7 +790,6 @@ prioritise_cast(Msg, _State) ->
delete_immediately -> 8;
{set_ram_duration_target, _Duration} -> 8;
{set_maximum_since_use, _Age} -> 8;
- emit_stats -> 7;
{ack, _AckTags, _ChPid} -> 7;
{reject, _AckTags, _Requeue, _ChPid} -> 7;
{notify_sent, _ChPid} -> 7;
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 6fbbc93e..4dd38fd6 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -23,7 +23,7 @@
-export([start_link/10, do/2, do/3, flush/1, shutdown/1]).
-export([send_command/2, deliver/4, flushed/2, confirm/2]).
-export([list/0, info_keys/0, info/1, info/2, info_all/0, info_all/1]).
--export([refresh_config_all/0, emit_stats/1, ready_for_close/1]).
+-export([refresh_config_all/0, ready_for_close/1]).
-export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2,
handle_info/2, handle_pre_hibernate/1, prioritise_call/3,
@@ -91,7 +91,6 @@
-spec(info_all/0 :: () -> [rabbit_types:infos()]).
-spec(info_all/1 :: (rabbit_types:info_keys()) -> [rabbit_types:infos()]).
-spec(refresh_config_all/0 :: () -> 'ok').
--spec(emit_stats/1 :: (pid()) -> 'ok').
-spec(ready_for_close/1 :: (pid()) -> 'ok').
-endif.
@@ -153,9 +152,6 @@ refresh_config_all() ->
fun (C) -> gen_server2:call(C, refresh_config) end, list()),
ok.
-emit_stats(Pid) ->
- gen_server2:cast(Pid, emit_stats).
-
ready_for_close(Pid) ->
gen_server2:cast(Pid, ready_for_close).
@@ -209,11 +205,15 @@ prioritise_call(Msg, _From, _State) ->
prioritise_cast(Msg, _State) ->
case Msg of
- emit_stats -> 7;
{confirm, _MsgSeqNos, _QPid} -> 5;
_ -> 0
end.
+prioritise_info(Msg, _State) ->
+ case Msg of
+ emit_stats -> 7
+ end.
+
handle_call(flush, _From, State) ->
reply(ok, State);
diff --git a/src/rabbit_event.erl b/src/rabbit_event.erl
index 887e4a1f..ef098a45 100644
--- a/src/rabbit_event.erl
+++ b/src/rabbit_event.erl
@@ -113,7 +113,7 @@ stop_stats_timer(State = #state{level = none}) ->
stop_stats_timer(State = #state{timer = undefined}) ->
State;
stop_stats_timer(State = #state{timer = TRef}) ->
- _ = erlang:cancel_timer(TRef),
+ rabbit_misc:cancel_timer(TRef),
State#state{timer = undefined}.
reset_stats_timer(State) ->
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 3bbfb1d7..337e3d6f 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -51,7 +51,7 @@
-export([recursive_delete/1, recursive_copy/2, dict_cons/3, orddict_cons/3]).
-export([get_options/2]).
-export([all_module_attributes/1, build_acyclic_graph/3]).
--export([now_ms/0]).
+-export([now_ms/0, cancel_timer/1]).
-export([lock_file/1]).
-export([const_ok/0, const/1]).
-export([ntoa/1, ntoab/1]).
@@ -832,6 +832,12 @@ get_flag(_, []) ->
now_ms() ->
timer:now_diff(now(), {0,0,0}) div 1000.
+cancel_timer(TRef) ->
+ case erlang:cancel_timer(TRef) of
+ false -> throw({not_a_valid_timer, TRef});
+ _ -> ok
+ end.
+
module_attributes(Module) ->
case catch Module:module_info(attributes) of
{'EXIT', {undef, [{Module, module_info, _} | _]}} ->
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl
index 6c5035a0..54424803 100644
--- a/src/rabbit_msg_store.erl
+++ b/src/rabbit_msg_store.erl
@@ -873,7 +873,7 @@ start_sync_timer(State = #msstate { sync_timer_ref = undefined }) ->
stop_sync_timer(State = #msstate { sync_timer_ref = undefined }) ->
State;
stop_sync_timer(State = #msstate { sync_timer_ref = TRef }) ->
- _ = erlang:cancel_timer(TRef),
+ rabbit_misc:cancel_timer(TRef),
State #msstate { sync_timer_ref = undefined }.
internal_sync(State = #msstate { current_file_handle = CurHdl,
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index 2a3ced92..ed4efb47 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -1287,7 +1287,7 @@ test_statistics_event_receiver(Pid) ->
test_statistics_receive_event(Ch, Matcher) ->
rabbit_channel:flush(Ch),
- rabbit_channel:emit_stats(Ch),
+ Ch ! emit_stats,
test_statistics_receive_event1(Ch, Matcher).
test_statistics_receive_event1(Ch, Matcher) ->