summaryrefslogtreecommitdiff
path: root/src/rabbit_networking.erl
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@lshift.net>2008-11-19 16:31:13 +0000
committerMatthias Radestock <matthias@lshift.net>2008-11-19 16:31:13 +0000
commit6fb1988c83c1a140ad1856963615860e1a58a6e9 (patch)
tree5c71f576167cd15f2b5c4badcd8d13e78740cfab /src/rabbit_networking.erl
parent8c0969ec73efbffd31a4d4196447d545ad1da2ac (diff)
downloadrabbitmq-server-6fb1988c83c1a140ad1856963615860e1a58a6e9.tar.gz
add connection_info functions
Diffstat (limited to 'src/rabbit_networking.erl')
-rw-r--r--src/rabbit_networking.erl23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/rabbit_networking.erl b/src/rabbit_networking.erl
index 9fc34503..df9b1b69 100644
--- a/src/rabbit_networking.erl
+++ b/src/rabbit_networking.erl
@@ -27,7 +27,8 @@
-export([start/0, start_tcp_listener/2, stop_tcp_listener/2,
on_node_down/1, active_listeners/0, node_listeners/1,
- connections/0]).
+ connections/0, connection_info/1, connection_info/2,
+ connection_info_all/0, connection_info_all/1]).
%%used by TCP-based transports, e.g. STOMP adapter
-export([check_tcp_listener_address/3]).
@@ -41,13 +42,18 @@
-ifdef(use_specs).
-type(host() :: ip_address() | string() | atom()).
+-type(connection() :: pid()).
-spec(start/0 :: () -> 'ok').
-spec(start_tcp_listener/2 :: (host(), ip_port()) -> 'ok').
-spec(stop_tcp_listener/2 :: (host(), ip_port()) -> 'ok').
-spec(active_listeners/0 :: () -> [listener()]).
-spec(node_listeners/1 :: (node()) -> [listener()]).
--spec(connections/0 :: () -> [pid()]).
+-spec(connections/0 :: () -> [connection()]).
+-spec(connection_info/1 :: (connection()) -> [info()]).
+-spec(connection_info/2 :: (connection(), [info_key()]) -> [info()]).
+-spec(connection_info_all/0 :: () -> [[info()]]).
+-spec(connection_info_all/1 :: ([info_key()]) -> [[info()]]).
-spec(on_node_down/1 :: (node()) -> 'ok').
-spec(check_tcp_listener_address/3 :: (atom(), host(), ip_port()) ->
{ip_address(), atom()}).
@@ -142,6 +148,12 @@ connections() ->
[Pid || {_, Pid, _, _} <- supervisor:which_children(
rabbit_tcp_client_sup)].
+connection_info(Pid) -> rabbit_reader:info(Pid).
+connection_info(Pid, Items) -> rabbit_reader:info(Pid, Items).
+
+connection_info_all() -> cmap(fun (Q) -> connection_info(Q) end).
+connection_info_all(Items) -> cmap(fun (Q) -> connection_info(Q, Items) end).
+
%%--------------------------------------------------------------------
tcp_host({0,0,0,0}) ->
@@ -155,3 +167,10 @@ tcp_host(IPAddress) ->
{ok, #hostent{h_name = Name}} -> Name;
{error, _Reason} -> inet_parse:ntoa(IPAddress)
end.
+
+cmap(F) ->
+ Ref = make_ref(),
+ lists:filter(fun (R) -> R =/= Ref end,
+ [rabbit_misc:with_exit_handler(
+ fun () -> Ref end,
+ fun () -> F(Q) end) || Q <- connections()]).