diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-12-05 15:33:49 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-12-05 15:33:49 +0000 |
commit | e5d86bf990699ba532d0997d4410b916ab06bf3f (patch) | |
tree | 01f0bb1038d12ca97617eb5866b0791dcd857230 | |
parent | b41498b6d1bdcd4660bb4076e1768dac2466b9de (diff) | |
download | rabbitmq-server-e5d86bf990699ba532d0997d4410b916ab06bf3f.tar.gz |
Store some process identity in the process dictionary.
-rw-r--r-- | src/rabbit_amqqueue_process.erl | 1 | ||||
-rw-r--r-- | src/rabbit_channel.erl | 1 | ||||
-rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 2 | ||||
-rw-r--r-- | src/rabbit_reader.erl | 1 | ||||
-rw-r--r-- | src/rabbit_writer.erl | 10 |
5 files changed, 12 insertions, 3 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 7002fd36..049df840 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -124,6 +124,7 @@ info_keys() -> ?INFO_KEYS. init(Q) -> process_flag(trap_exit, true), + put(rabbit_process_name, {queue, Q#amqqueue.name}), {ok, init_state(Q#amqqueue{pid = self()}), hibernate, {backoff, ?HIBERNATE_AFTER_MIN, ?HIBERNATE_AFTER_MIN, ?DESIRED_HIBERNATE}}. diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 4d778f94..dbf66dcf 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -195,6 +195,7 @@ init([Channel, ReaderPid, WriterPid, ConnPid, ConnName, Protocol, User, VHost, Capabilities, CollectorPid, LimiterPid]) -> process_flag(trap_exit, true), ok = pg_local:join(rabbit_channels, self()), + put(rabbit_process_name, {channel, {ConnName, Channel}}), State = #ch{state = starting, protocol = Protocol, channel = Channel, diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index 96f89ecc..211b99c0 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -79,6 +79,7 @@ set_maximum_since_use(QPid, Age) -> info(QPid) -> gen_server2:call(QPid, info, infinity). init(Q) -> + put(rabbit_process_name, {queue_slave, Q#amqqueue.name}), {ok, {not_started, Q}, hibernate, {backoff, ?HIBERNATE_AFTER_MIN, ?HIBERNATE_AFTER_MIN, ?DESIRED_HIBERNATE}}. @@ -616,6 +617,7 @@ promote_me(From, #state { q = Q = #amqqueue { name = QName }, KS1 = lists:foldl(fun (ChPid0, KS0) -> pmon:demonitor(ChPid0, KS0) end, KS, AwaitGmDown), + put(rabbit_process_name, {queue, QName}), rabbit_amqqueue_process:init_with_backing_queue_state( Q1, rabbit_mirror_queue_master, MasterState, RateTRef, Deliveries, KS1, MTC). diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index 2221ca79..162409d0 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -212,6 +212,7 @@ start_connection(Parent, HelperSup, Deb, Sock, SockTransform) -> erlang:send_after(?HANDSHAKE_TIMEOUT * 1000, self(), handshake_timeout), {PeerHost, PeerPort, Host, Port} = socket_op(Sock, fun (S) -> rabbit_net:socket_ends(S, inbound) end), + put(rabbit_process_name, {reader, list_to_binary(Name)}), State = #v1{parent = Parent, sock = ClientSock, connection = #connection{ diff --git a/src/rabbit_writer.erl b/src/rabbit_writer.erl index 34dd3d3b..77521ca5 100644 --- a/src/rabbit_writer.erl +++ b/src/rabbit_writer.erl @@ -30,7 +30,7 @@ -export([internal_send_command/4, internal_send_command/6]). %% internal --export([mainloop/2, mainloop1/2]). +-export([enter_mainloop/2, mainloop/2, mainloop1/2]). -record(wstate, {sock, channel, frame_max, protocol, reader, stats_timer, pending}). @@ -109,13 +109,13 @@ start(Sock, Channel, FrameMax, Protocol, ReaderPid, ReaderWantsStats) -> State = initial_state(Sock, Channel, FrameMax, Protocol, ReaderPid, ReaderWantsStats), Deb = sys:debug_options([]), - {ok, proc_lib:spawn(?MODULE, mainloop, [Deb, State])}. + {ok, proc_lib:spawn(?MODULE, enter_mainloop, [Deb, State])}. start_link(Sock, Channel, FrameMax, Protocol, ReaderPid, ReaderWantsStats) -> State = initial_state(Sock, Channel, FrameMax, Protocol, ReaderPid, ReaderWantsStats), Deb = sys:debug_options([]), - {ok, proc_lib:spawn_link(?MODULE, mainloop, [Deb, State])}. + {ok, proc_lib:spawn_link(?MODULE, enter_mainloop, [Deb, State])}. initial_state(Sock, Channel, FrameMax, Protocol, ReaderPid, ReaderWantsStats) -> (case ReaderWantsStats of @@ -138,6 +138,10 @@ system_terminate(Reason, _Parent, _Deb, _State) -> system_code_change(Misc, _Module, _OldVsn, _Extra) -> {ok, Misc}. +enter_mainloop(Deb, State = #wstate{channel = Channel}) -> + put(rabbit_process_name, {writer, unknown, Channel}), + mainloop(Deb, State). + mainloop(Deb, State) -> try mainloop1(Deb, State) |