Skip to content

Commit 08e35ea

Browse files
committed
merge default into bug21596
2 parents 0987dd4 + c0200cb commit 08e35ea

File tree

6 files changed

+44
-40
lines changed

6 files changed

+44
-40
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

src/gen_server2.erl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,10 @@ unregister_name({local,Name}) ->
437437
unregister_name({global,Name}) ->
438438
_ = global:unregister_name(Name);
439439
unregister_name(Pid) when is_pid(Pid) ->
440-
Pid.
440+
Pid;
441+
% Under R12 let's just ignore it, as we have a single term as Name.
442+
% On R13 it will never get here, as we get tuple with 'local/global' atom.
443+
unregister_name(_Name) -> ok.
441444

442445
extend_backoff(undefined) ->
443446
undefined;

src/rabbit_channel.erl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ handle_cast({method, Method, Content}, State) ->
126126
{stop, normal, State#ch{state = terminating}}
127127
catch
128128
exit:{amqp, Error, Explanation, none} ->
129-
ok = notify_queues(internal_rollback(State)),
129+
ok = rollback_and_notify(State),
130130
Reason = {amqp, Error, Explanation,
131131
rabbit_misc:method_record_type(Method)},
132132
State#ch.reader_pid ! {channel_exit, State#ch.channel, Reason},
@@ -175,7 +175,7 @@ terminate(_Reason, #ch{writer_pid = WriterPid, limiter_pid = LimiterPid,
175175

176176
terminate(Reason, State = #ch{writer_pid = WriterPid,
177177
limiter_pid = LimiterPid}) ->
178-
Res = notify_queues(internal_rollback(State)),
178+
Res = rollback_and_notify(State),
179179
case Reason of
180180
normal -> ok = Res;
181181
_ -> ok
@@ -297,7 +297,7 @@ handle_method(_Method, _, #ch{state = starting}) ->
297297
rabbit_misc:protocol_error(channel_error, "expected 'channel.open'", []);
298298

299299
handle_method(#'channel.close'{}, _, State = #ch{writer_pid = WriterPid}) ->
300-
ok = notify_queues(internal_rollback(State)),
300+
ok = rollback_and_notify(State),
301301
ok = rabbit_writer:send_command(WriterPid, #'channel.close_ok'{}),
302302
stop;
303303

@@ -872,6 +872,11 @@ internal_rollback(State = #ch{transaction_id = TxnKey,
872872
internal_error, "rollback failed: ~w", [Errors])
873873
end.
874874

875+
rollback_and_notify(State = #ch{transaction_id = none}) ->
876+
notify_queues(State);
877+
rollback_and_notify(State) ->
878+
notify_queues(internal_rollback(State)).
879+
875880
fold_per_queue(F, Acc0, UAQ) ->
876881
D = lists:foldl(
877882
fun ({_DTag, _CTag,

src/rabbit_control.erl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ default_if_empty(List, Default) when is_list(List) ->
315315
end.
316316

317317
display_info_list(Results, InfoItemKeys) when is_list(Results) ->
318-
lists:foreach(fun (Result) -> display_row([format_info_item(Result, X) ||
318+
lists:foreach(fun (Result) -> display_row([format_info_item(X, Result) ||
319319
X <- InfoItemKeys])
320320
end, Results),
321321
ok;
@@ -326,20 +326,20 @@ display_row(Row) ->
326326
io:fwrite(lists:flatten(rabbit_misc:intersperse("\t", Row))),
327327
io:nl().
328328

329-
format_info_item(Items, Key) ->
330-
{value, Info = {Key, Value}} = lists:keysearch(Key, 1, Items),
331-
case Info of
332-
{_, #resource{name = Name}} ->
329+
format_info_item(Key, Items) ->
330+
case proplists:get_value(Key, Items) of
331+
#resource{name = Name} ->
333332
escape(Name);
334-
_ when Key =:= address; Key =:= peer_address andalso is_tuple(Value) ->
333+
Value when Key =:= address; Key =:= peer_address andalso
334+
is_tuple(Value) ->
335335
inet_parse:ntoa(Value);
336-
_ when is_pid(Value) ->
336+
Value when is_pid(Value) ->
337337
atom_to_list(node(Value));
338-
_ when is_binary(Value) ->
338+
Value when is_binary(Value) ->
339339
escape(Value);
340-
_ when is_atom(Value) ->
340+
Value when is_atom(Value) ->
341341
io_lib:format("~s", [Value]);
342-
_ ->
342+
Value ->
343343
io_lib:format("~w", [Value])
344344
end.
345345

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,

0 commit comments

Comments
 (0)