summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2010-07-29 17:16:09 +0100
committerSimon MacMullen <simon@rabbitmq.com>2010-07-29 17:16:09 +0100
commitc35a63df59fe511b5b26bc843c4db6527e324881 (patch)
tree5254471d9dc440934513f633eecd03832efc0a38
parent1d801e1f4a3675644430c773a0ef745ca8b19ad4 (diff)
downloadrabbitmq-server-c35a63df59fe511b5b26bc843c4db6527e324881.tar.gz
Cosmetics, add pid to CREATION_EVENT_KEYS, don't emit stats when stopping when timer does not exist.
-rw-r--r--src/rabbit_amqqueue_process.erl23
-rw-r--r--src/rabbit_channel.erl23
-rw-r--r--src/rabbit_event.erl1
-rw-r--r--src/rabbit_reader.erl29
4 files changed, 36 insertions, 40 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index a69891e4..ab30ea3a 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -88,14 +88,15 @@
]).
-define(CREATION_EVENT_KEYS,
- [name,
+ [pid,
+ name,
durable,
auto_delete,
arguments,
owner_pid
]).
--define(INFO_KEYS, ?CREATION_EVENT_KEYS ++ ?STATISTICS_KEYS).
+-define(INFO_KEYS, ?CREATION_EVENT_KEYS ++ ?STATISTICS_KEYS -- [pid]).
%%----------------------------------------------------------------------------
@@ -165,7 +166,7 @@ declare(Recover, From,
rabbit_event:notify(
queue_created,
[{Item, i(Item, State)} ||
- Item <- [pid|?CREATION_EVENT_KEYS]]),
+ Item <- ?CREATION_EVENT_KEYS]),
noreply(init_expires(State#q{backing_queue_state = BQS}));
Q1 -> {stop, normal, {existing, Q1}, State}
end.
@@ -264,17 +265,15 @@ ensure_expiry_timer(State = #q{expires = Expires}) ->
ensure_stats_timer(State = #q{stats_timer = StatsTimer,
q = Q}) ->
- StatsTimer1 = rabbit_event:ensure_stats_timer(
- StatsTimer,
- fun() -> emit_stats(State) end,
- fun() -> rabbit_amqqueue:emit_stats(Q) end),
- State#q{stats_timer = StatsTimer1}.
+ State#q{stats_timer = rabbit_event:ensure_stats_timer(
+ StatsTimer,
+ fun() -> emit_stats(State) end,
+ fun() -> rabbit_amqqueue:emit_stats(Q) end)}.
stop_stats_timer(State = #q{stats_timer = StatsTimer}) ->
- StatsTimer1 = rabbit_event:stop_stats_timer(
- StatsTimer,
- fun() -> emit_stats(State) end),
- State#q{stats_timer = StatsTimer1}.
+ State#q{stats_timer = rabbit_event:stop_stats_timer(
+ StatsTimer,
+ fun() -> emit_stats(State) end)}.
assert_invariant(#q{active_consumers = AC,
backing_queue = BQ, backing_queue_state = BQS}) ->
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 0b3fd380..5117fc37 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -66,12 +66,13 @@
prefetch_count]).
-define(CREATION_EVENT_KEYS,
- [connection,
+ [pid,
+ connection,
number,
user,
vhost]).
--define(INFO_KEYS, ?CREATION_EVENT_KEYS ++ ?STATISTICS_KEYS).
+-define(INFO_KEYS, ?CREATION_EVENT_KEYS ++ ?STATISTICS_KEYS -- [pid]).
%%----------------------------------------------------------------------------
@@ -191,7 +192,7 @@ init([Channel, ReaderPid, WriterPid, Username, VHost, CollectorPid]) ->
stats_timer = rabbit_event:init_stats_timer()},
rabbit_event:notify(
channel_created,
- [{Item, i(Item, State)} || Item <- [pid|?CREATION_EVENT_KEYS]]),
+ [{Item, i(Item, State)} || Item <- ?CREATION_EVENT_KEYS]),
{ok, State, hibernate,
{backoff, ?HIBERNATE_AFTER_MIN, ?HIBERNATE_AFTER_MIN, ?DESIRED_HIBERNATE}}.
@@ -315,17 +316,15 @@ noreply(NewState) ->
ensure_stats_timer(State = #ch{stats_timer = StatsTimer}) ->
ChPid = self(),
- StatsTimer1 = rabbit_event:ensure_stats_timer(
- StatsTimer,
- fun() -> internal_emit_stats(State) end,
- fun() -> emit_stats(ChPid) end),
- State#ch{stats_timer = StatsTimer1}.
+ State#ch{stats_timer = rabbit_event:ensure_stats_timer(
+ StatsTimer,
+ fun() -> internal_emit_stats(State) end,
+ fun() -> emit_stats(ChPid) end)}.
stop_stats_timer(State = #ch{stats_timer = StatsTimer}) ->
- StatsTimer1 = rabbit_event:stop_stats_timer(
- StatsTimer,
- fun() -> internal_emit_stats(State) end),
- State#ch{stats_timer = StatsTimer1}.
+ State#ch{stats_timer = rabbit_event:stop_stats_timer(
+ StatsTimer,
+ fun() -> internal_emit_stats(State) end)}.
return_ok(State, true, _Msg) -> {noreply, State};
return_ok(State, false, Msg) -> {reply, Msg, State}.
diff --git a/src/rabbit_event.erl b/src/rabbit_event.erl
index 6cd48078..629f5a77 100644
--- a/src/rabbit_event.erl
+++ b/src/rabbit_event.erl
@@ -60,7 +60,6 @@ ensure_stats_timer(State, _NowFun, _TimerFun) ->
stop_stats_timer(State = #state{level = none}, _NowFun) ->
State;
stop_stats_timer(State = #state{timer = undefined}, NowFun) ->
- NowFun(),
State;
stop_stats_timer(State = #state{timer = TRef}, NowFun) ->
{ok, cancel} = timer:cancel(TRef),
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index e1e4662b..c24729a2 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -65,11 +65,11 @@
-define(STATISTICS_KEYS, [pid, recv_oct, recv_cnt, send_oct, send_cnt,
send_pend, state, channels]).
--define(CREATION_EVENT_KEYS, [address, port, peer_address, peer_port,
+-define(CREATION_EVENT_KEYS, [pid, address, port, peer_address, peer_port,
user, vhost, timeout, frame_max,
client_properties]).
--define(INFO_KEYS, ?CREATION_EVENT_KEYS ++ ?STATISTICS_KEYS).
+-define(INFO_KEYS, ?CREATION_EVENT_KEYS ++ ?STATISTICS_KEYS -- [pid]).
%% connection lifecycle
%%
@@ -603,20 +603,19 @@ check_version(ClientVersion, ServerVersion) ->
ensure_stats_timer(State = #v1{stats_timer = StatsTimer}) ->
ReaderPid = self(),
- StatsTimer1 = 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),
- State#v1{stats_timer = StatsTimer1}.
+ 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}) ->
- StatsTimer1 = rabbit_event:stop_stats_timer(
- StatsTimer,
- fun() -> internal_emit_stats(State) end),
- State#v1{stats_timer = StatsTimer1}.
+ State#v1{stats_timer = rabbit_event:stop_stats_timer(
+ StatsTimer,
+ fun() -> internal_emit_stats(State) end)}.
%%--------------------------------------------------------------------------
@@ -696,7 +695,7 @@ handle_method0(#'connection.open'{virtual_host = VHostPath,
connection = NewConnection},
rabbit_event:notify(
connection_created,
- [{Item, i(Item, State1)} || Item <- [pid|?CREATION_EVENT_KEYS]]),
+ [{Item, i(Item, State1)} || Item <- ?CREATION_EVENT_KEYS]),
State1;
true ->
%% FIXME: 'host' is supposed to only contain one