summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2010-07-29 17:36:26 +0100
committerSimon MacMullen <simon@rabbitmq.com>2010-07-29 17:36:26 +0100
commit3fe0f79fb112f51e586fec07d07c8fb392066033 (patch)
tree2cbffc7f753a7a3c464433d749509650ae38fe67
parentc35a63df59fe511b5b26bc843c4db6527e324881 (diff)
downloadrabbitmq-server-3fe0f79fb112f51e586fec07d07c8fb392066033.tar.gz
Revert reader changes in 1451c9523971 sicne they force us to start / stop a timer all the time.
-rw-r--r--src/rabbit_reader.erl33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index c24729a2..ffd40bed 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -60,7 +60,7 @@
%---------------------------------------------------------------------------
-record(v1, {sock, connection, callback, recv_ref, connection_state,
- queue_collector, stats_timer}).
+ queue_collector, stats_timer_ref, stats_level}).
-define(STATISTICS_KEYS, [pid, recv_oct, recv_cnt, send_oct, send_cnt,
send_pend, state, channels]).
@@ -251,6 +251,7 @@ start_connection(Parent, Deb, Sock, SockTransform) ->
handshake_timeout),
ProfilingValue = setup_profiling(),
{ok, Collector} = rabbit_queue_collector:start_link(),
+ {ok, StatsLevel} = application:get_env(rabbit, collect_statistics),
try
mainloop(Parent, Deb, switch_callback(
#v1{sock = ClientSock,
@@ -264,8 +265,8 @@ start_connection(Parent, Deb, Sock, SockTransform) ->
recv_ref = none,
connection_state = pre_init,
queue_collector = Collector,
- stats_timer =
- rabbit_event:init_stats_timer()},
+ stats_timer_ref = undefined,
+ stats_level = StatsLevel},
handshake, 8))
catch
Ex -> (if Ex == connection_closed_abruptly ->
@@ -353,7 +354,8 @@ mainloop(Parent, Deb, State = #v1{sock= Sock, recv_ref = Ref}) ->
end),
mainloop(Parent, Deb, State);
{'$gen_cast', emit_stats} ->
- mainloop(Parent, Deb, stop_stats_timer(State));
+ internal_emit_stats(State),
+ mainloop(Parent, Deb, State#v1{stats_timer_ref = undefined});
{system, From, Request} ->
sys:handle_system_msg(Request, From,
Parent, ?MODULE, Deb, State);
@@ -601,21 +603,14 @@ check_version(ClientVersion, ServerVersion) ->
(ClientMajor == ServerMajor andalso
ClientMinor >= ServerMinor).
-ensure_stats_timer(State = #v1{stats_timer = StatsTimer}) ->
- ReaderPid = self(),
- State#v1{stats_timer = rabbit_event:ensure_stats_timer(
- StatsTimer,
- %% Don't run internal_emit_stats here, in normal
- %% use ensure_stats_timer will get invoked almost
- %% immediately after stop_stats_timer and we'll
- %% emit double events
- fun() -> ok end,
- fun() -> emit_stats(ReaderPid) end)}.
-
-stop_stats_timer(State = #v1{stats_timer = StatsTimer}) ->
- State#v1{stats_timer = rabbit_event:stop_stats_timer(
- StatsTimer,
- fun() -> internal_emit_stats(State) end)}.
+ensure_stats_timer(State = #v1{stats_level = none}) ->
+ State;
+ensure_stats_timer(State = #v1{stats_timer_ref = undefined}) ->
+ {ok, TRef} = timer:apply_after(?STATS_INTERVAL,
+ rabbit_reader, emit_stats, [self()]),
+ State#v1{stats_timer_ref = TRef};
+ensure_stats_timer(State) ->
+ State.
%%--------------------------------------------------------------------------