diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2010-09-13 11:05:32 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2010-09-13 11:05:32 +0100 |
commit | a03e474f875b20c27617d72f407b206285142152 (patch) | |
tree | 4d99cd5fe5817974fd316478518a143bad346d98 | |
parent | 12c8c622775e7d96638296ecabe6082d4e4d8b96 (diff) | |
parent | aa067e39b4339bd3d3feac49c81a6f7ebf24e2bf (diff) | |
download | rabbitmq-server-a03e474f875b20c27617d72f407b206285142152.tar.gz |
Merge default into bug23193
-rw-r--r-- | src/rabbit_amqqueue_process.erl | 12 | ||||
-rw-r--r-- | src/rabbit_channel.erl | 7 | ||||
-rw-r--r-- | src/rabbit_reader.erl | 7 |
3 files changed, 21 insertions, 5 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 08495862..d07aa99e 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -152,7 +152,8 @@ init_expires(State = #q{q = #amqqueue{arguments = Arguments}}) -> declare(Recover, From, State = #q{q = Q = #amqqueue{name = QName, durable = IsDurable}, - backing_queue = BQ, backing_queue_state = undefined}) -> + backing_queue = BQ, backing_queue_state = undefined, + stats_timer = StatsTimer}) -> case rabbit_amqqueue:internal_declare(Q, Recover) of not_found -> {stop, normal, not_found, State}; Q -> gen_server2:reply(From, {new, Q}), @@ -163,9 +164,14 @@ declare(Recover, From, self(), {rabbit_amqqueue, set_ram_duration_target, [self()]}), BQS = BQ:init(QName, IsDurable, Recover), + State1 = init_expires(State#q{backing_queue_state = BQS}), rabbit_event:notify(queue_created, - infos(?CREATION_EVENT_KEYS, State)), - noreply(init_expires(State#q{backing_queue_state = BQS})); + infos(?CREATION_EVENT_KEYS, State1)), + case rabbit_event:stats_level(StatsTimer) of + none -> ok; + _ -> emit_stats(State1) + end, + noreply(State1); Q1 -> {stop, normal, {existing, Q1}, State} end. diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 174eab40..d518e59b 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -157,6 +157,7 @@ init([Channel, ReaderPid, WriterPid, Username, VHost, CollectorPid, StartLimiterFun]) -> process_flag(trap_exit, true), ok = pg_local:join(rabbit_channels, self()), + StatsTimer = rabbit_event:init_stats_timer(), State = #ch{state = starting, channel = Channel, reader_pid = ReaderPid, @@ -174,8 +175,12 @@ init([Channel, ReaderPid, WriterPid, Username, VHost, CollectorPid, consumer_mapping = dict:new(), blocking = dict:new(), queue_collector_pid = CollectorPid, - stats_timer = rabbit_event:init_stats_timer()}, + stats_timer = StatsTimer}, rabbit_event:notify(channel_created, infos(?CREATION_EVENT_KEYS, State)), + case rabbit_event:stats_level(StatsTimer) of + none -> ok; + _ -> internal_emit_stats(State) + end, {ok, State, hibernate, {backoff, ?HIBERNATE_AFTER_MIN, ?HIBERNATE_AFTER_MIN, ?DESIRED_HIBERNATE}}. diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index a21961b5..795a2a92 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -765,7 +765,8 @@ handle_method0(#'connection.open'{virtual_host = VHostPath}, connection = Connection = #connection{ user = User, protocol = Protocol}, - sock = Sock}) -> + sock = Sock, + stats_timer = StatsTimer}) -> ok = rabbit_access_control:check_vhost_access(User, VHostPath), NewConnection = Connection#connection{vhost = VHostPath}, ok = send_on_channel0(Sock, #'connection.open_ok'{}, Protocol), @@ -775,6 +776,10 @@ handle_method0(#'connection.open'{virtual_host = VHostPath}, connection = NewConnection}), rabbit_event:notify(connection_created, infos(?CREATION_EVENT_KEYS, State1)), + case rabbit_event:stats_level(StatsTimer) of + none -> ok; + _ -> internal_emit_stats(State1) + end, State1; handle_method0(#'connection.close'{}, State) when ?IS_RUNNING(State) -> lists:foreach(fun rabbit_framing_channel:shutdown/1, all_channels()), |