Skip to content

Commit d628253

Browse files
author
Matthias Radestock
committed
merge default into bug20399
2 parents 0a46932 + 5ed1782 commit d628253

File tree

7 files changed

+43
-42
lines changed

7 files changed

+43
-42
lines changed

.hgignore

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ erl_crash.dump
88
syntax: regexp
99
^cover/
1010
^dist/
11-
^include/rabbit_framing.hrl$
12-
^src/rabbit_framing.erl$
13-
^rabbit.plt$
14-
^ebin/rabbit.app$
15-
^ebin/rabbit.rel$
16-
^ebin/rabbit.boot$
17-
^ebin/rabbit.script$
11+
^include/rabbit_framing\.hrl$
12+
^src/rabbit_framing\.erl$
13+
^rabbit\.plt$
14+
^ebin/rabbit\.(app|rel|boot|script)$
1815
^plugins/
1916
^priv/plugins/
2017

docs/rabbitmqctl.1.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ separated by tab characters.
287287
List queue information by virtual host. Each line printed describes an
288288
connection, with the requested I<connectioninfoitem> values separated
289289
by tab characters. If no I<connectioninfoitem>s are specified then
290-
I<user>, I<peer_address> and I<peer_port> are assumed.
290+
I<user>, I<peer_address>, I<peer_port> and I<state> are assumed.
291291

292292
=back
293293

packaging/common/rabbitmq-script-wrapper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
## The contents of this file are subject to the Mozilla Public License
33
## Version 1.1 (the "License"); you may not use this file except in
44
## compliance with the License. You may obtain a copy of the License at

src/rabbit_control.erl

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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,
165165
peer_address, peer_port, state, channels, user, vhost, timeout, frame_max,
166166
recv_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

271271
action(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

316317
display_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

364367
escape(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

367372
escape_char([$\\ | T], Acc) ->
368373
escape_char(T, [$\\, $\\ | Acc]);

src/rabbit_multi.erl

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@ action(status, [], RpcTimeout) ->
114114
io:format("Status of all running nodes...~n", []),
115115
call_all_nodes(
116116
fun({Node, Pid}) ->
117-
Status = rpc:call(Node, rabbit, status, [], RpcTimeout),
117+
RabbitRunning =
118+
case is_rabbit_running(Node, RpcTimeout) of
119+
false -> not_running;
120+
true -> running
121+
end,
118122
io:format("Node '~p' with Pid ~p: ~p~n",
119-
[Node, Pid, case parse_status(Status) of
120-
false -> not_running;
121-
true -> running
122-
end])
123+
[Node, Pid, RabbitRunning])
123124
end);
124125

125126
action(stop_all, [], RpcTimeout) ->
@@ -197,7 +198,7 @@ start_node(NodeName, NodePort, RpcTimeout) ->
197198
wait_for_rabbit_to_start(_ , RpcTimeout, _) when RpcTimeout < 0 ->
198199
false;
199200
wait_for_rabbit_to_start(Node, RpcTimeout, Port) ->
200-
case parse_status(rpc:call(Node, rabbit, status, [])) of
201+
case is_rabbit_running(Node, RpcTimeout) of
201202
true -> true;
202203
false -> receive
203204
{'EXIT', Port, PosixCode} ->
@@ -211,22 +212,20 @@ wait_for_rabbit_to_start(Node, RpcTimeout, Port) ->
211212
run_cmd(FullPath) ->
212213
erlang:open_port({spawn, FullPath}, [nouse_stdio]).
213214

214-
parse_status({badrpc, _}) ->
215-
false;
216-
217-
parse_status(Status) ->
218-
case lists:keysearch(running_applications, 1, Status) of
219-
{value, {running_applications, Apps}} ->
220-
lists:keymember(rabbit, 1, Apps);
221-
_ ->
222-
false
215+
is_rabbit_running(Node, RpcTimeout) ->
216+
case rpc:call(Node, rabbit, status, [], RpcTimeout) of
217+
{badrpc, _} -> false;
218+
Status -> case proplists:get_value(running_applications, Status) of
219+
undefined -> false;
220+
Apps -> lists:keymember(rabbit, 1, Apps)
221+
end
223222
end.
224223

225224
with_os(Handlers) ->
226225
{OsFamily, _} = os:type(),
227-
case lists:keysearch(OsFamily, 1, Handlers) of
228-
{value, {_, Handler}} -> Handler();
229-
false -> throw({unsupported_os, OsFamily})
226+
case proplists:get_value(OsFamily, Handlers) of
227+
undefined -> throw({unsupported_os, OsFamily});
228+
Handler -> Handler()
230229
end.
231230

232231
script_filename() ->

src/rabbit_plugin_activator.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ start() ->
6868
AppList
6969
end,
7070
AppVersions = [determine_version(App) || App <- AllApps],
71-
{value, {rabbit, RabbitVersion}} = lists:keysearch(rabbit, 1, AppVersions),
71+
{rabbit, RabbitVersion} = proplists:lookup(rabbit, AppVersions),
7272

7373
%% Build the overall release descriptor
7474
RDesc = {release,

src/rabbit_reader.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ i(channels, #v1{}) ->
702702
i(user, #v1{connection = #connection{user = #user{username = Username}}}) ->
703703
Username;
704704
i(user, #v1{connection = #connection{user = none}}) ->
705-
none;
705+
'';
706706
i(vhost, #v1{connection = #connection{vhost = VHost}}) ->
707707
VHost;
708708
i(timeout, #v1{connection = #connection{timeout_sec = Timeout}}) ->

0 commit comments

Comments
 (0)