@@ -164,7 +164,7 @@ exchange name, routing key, queue name and arguments, in that order.
164164<ConnectionInfoItem> must be a member of the list [node, address, port,
165165peer_address, peer_port, state, channels, user, vhost, timeout, frame_max,
166166recv_oct, recv_cnt, send_oct, send_cnt, send_pend]. The default is to display
167- user, peer_address and peer_port .
167+ user, peer_address, peer_port and state .
168168
169169" ),
170170 halt (1 ).
@@ -270,8 +270,9 @@ action(list_bindings, Node, Args, Inform) ->
270270
271271action (list_connections , Node , Args , Inform ) ->
272272 Inform (" Listing connections" , []),
273- ArgAtoms = list_replace (node , pid ,
274- default_if_empty (Args , [user , peer_address , peer_port ])),
273+ ArgAtoms = list_replace (node , pid ,
274+ default_if_empty (Args , [user , peer_address ,
275+ peer_port , state ])),
275276 display_info_list (rpc_call (Node , rabbit_networking , connection_info_all ,
276277 [ArgAtoms ]),
277278 ArgAtoms );
@@ -314,7 +315,7 @@ default_if_empty(List, Default) when is_list(List) ->
314315 end .
315316
316317display_info_list (Results , InfoItemKeys ) when is_list (Results ) ->
317- lists :foreach (fun (Result ) -> display_row ([format_info_item (Result , X ) ||
318+ lists :foreach (fun (Result ) -> display_row ([format_info_item (X , Result ) ||
318319 X <- InfoItemKeys ])
319320 end , Results ),
320321 ok ;
@@ -325,18 +326,20 @@ display_row(Row) ->
325326 io :fwrite (lists :flatten (rabbit_misc :intersperse (" \t " , Row ))),
326327 io :nl ().
327328
328- format_info_item (Items , Key ) ->
329- {value , Info = {Key , Value }} = lists :keysearch (Key , 1 , Items ),
330- case Info of
331- {_ , # resource {name = Name }} ->
329+ format_info_item (Key , Items ) ->
330+ case proplists :get_value (Key , Items ) of
331+ # resource {name = Name } ->
332332 escape (Name );
333- _ when Key =:= address ; Key =:= peer_address andalso is_tuple (Value ) ->
333+ Value when Key =:= address ; Key =:= peer_address andalso
334+ is_tuple (Value ) ->
334335 inet_parse :ntoa (Value );
335- _ when is_pid (Value ) ->
336+ Value when is_pid (Value ) ->
336337 atom_to_list (node (Value ));
337- _ when is_binary (Value ) ->
338+ Value when is_binary (Value ) ->
338339 escape (Value );
339- _ ->
340+ Value when is_atom (Value ) ->
341+ escape (atom_to_list (Value ));
342+ Value ->
340343 io_lib :format (" ~w " , [Value ])
341344 end .
342345
@@ -362,7 +365,9 @@ rpc_call(Node, Mod, Fun, Args) ->
362365% % form part of UTF-8 strings.
363366
364367escape (Bin ) when binary (Bin ) ->
365- escape_char (lists :reverse (binary_to_list (Bin )), []).
368+ escape (binary_to_list (Bin ));
369+ escape (L ) when is_list (L ) ->
370+ escape_char (lists :reverse (L ), []).
366371
367372escape_char ([$\\ | T ], Acc ) ->
368373 escape_char (T , [$\\ , $\\ | Acc ]);
0 commit comments