summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTony Garnock-Jones <tonyg@lshift.net>2009-09-18 12:49:00 +0100
committerTony Garnock-Jones <tonyg@lshift.net>2009-09-18 12:49:00 +0100
commit08e35ea4e7d9566ee046a16d8621e92b278d2562 (patch)
treea6cce5107e3875db21aae98f62981f549faecb55 /src
parent0987dd424bc04a7f986ee5cc8ab399f646554c72 (diff)
parentc0200cb4a37d2365a64bc4147da3ce81bd14da62 (diff)
downloadrabbitmq-server-git-08e35ea4e7d9566ee046a16d8621e92b278d2562.tar.gz
merge default into bug21596
Diffstat (limited to 'src')
-rw-r--r--src/gen_server2.erl5
-rw-r--r--src/rabbit_channel.erl11
-rw-r--r--src/rabbit_control.erl20
-rw-r--r--src/rabbit_multi.erl35
-rw-r--r--src/rabbit_plugin_activator.erl2
5 files changed, 40 insertions, 33 deletions
diff --git a/src/gen_server2.erl b/src/gen_server2.erl
index 36fb4fa8c3..a2d9350c4e 100644
--- a/src/gen_server2.erl
+++ b/src/gen_server2.erl
@@ -437,7 +437,10 @@ unregister_name({local,Name}) ->
unregister_name({global,Name}) ->
_ = global:unregister_name(Name);
unregister_name(Pid) when is_pid(Pid) ->
- Pid.
+ Pid;
+% Under R12 let's just ignore it, as we have a single term as Name.
+% On R13 it will never get here, as we get tuple with 'local/global' atom.
+unregister_name(_Name) -> ok.
extend_backoff(undefined) ->
undefined;
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 16b7c938ca..1285064f43 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -126,7 +126,7 @@ handle_cast({method, Method, Content}, State) ->
{stop, normal, State#ch{state = terminating}}
catch
exit:{amqp, Error, Explanation, none} ->
- ok = notify_queues(internal_rollback(State)),
+ ok = rollback_and_notify(State),
Reason = {amqp, Error, Explanation,
rabbit_misc:method_record_type(Method)},
State#ch.reader_pid ! {channel_exit, State#ch.channel, Reason},
@@ -175,7 +175,7 @@ terminate(_Reason, #ch{writer_pid = WriterPid, limiter_pid = LimiterPid,
terminate(Reason, State = #ch{writer_pid = WriterPid,
limiter_pid = LimiterPid}) ->
- Res = notify_queues(internal_rollback(State)),
+ Res = rollback_and_notify(State),
case Reason of
normal -> ok = Res;
_ -> ok
@@ -297,7 +297,7 @@ handle_method(_Method, _, #ch{state = starting}) ->
rabbit_misc:protocol_error(channel_error, "expected 'channel.open'", []);
handle_method(#'channel.close'{}, _, State = #ch{writer_pid = WriterPid}) ->
- ok = notify_queues(internal_rollback(State)),
+ ok = rollback_and_notify(State),
ok = rabbit_writer:send_command(WriterPid, #'channel.close_ok'{}),
stop;
@@ -872,6 +872,11 @@ internal_rollback(State = #ch{transaction_id = TxnKey,
internal_error, "rollback failed: ~w", [Errors])
end.
+rollback_and_notify(State = #ch{transaction_id = none}) ->
+ notify_queues(State);
+rollback_and_notify(State) ->
+ notify_queues(internal_rollback(State)).
+
fold_per_queue(F, Acc0, UAQ) ->
D = lists:foldl(
fun ({_DTag, _CTag,
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index 5f599ccf2d..ac7e3eaa9c 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -315,7 +315,7 @@ default_if_empty(List, Default) when is_list(List) ->
end.
display_info_list(Results, InfoItemKeys) when is_list(Results) ->
- lists:foreach(fun (Result) -> display_row([format_info_item(Result, X) ||
+ lists:foreach(fun (Result) -> display_row([format_info_item(X, Result) ||
X <- InfoItemKeys])
end, Results),
ok;
@@ -326,20 +326,20 @@ display_row(Row) ->
io:fwrite(lists:flatten(rabbit_misc:intersperse("\t", Row))),
io:nl().
-format_info_item(Items, Key) ->
- {value, Info = {Key, Value}} = lists:keysearch(Key, 1, Items),
- case Info of
- {_, #resource{name = Name}} ->
+format_info_item(Key, Items) ->
+ case proplists:get_value(Key, Items) of
+ #resource{name = Name} ->
escape(Name);
- _ when Key =:= address; Key =:= peer_address andalso is_tuple(Value) ->
+ Value when Key =:= address; Key =:= peer_address andalso
+ is_tuple(Value) ->
inet_parse:ntoa(Value);
- _ when is_pid(Value) ->
+ Value when is_pid(Value) ->
atom_to_list(node(Value));
- _ when is_binary(Value) ->
+ Value when is_binary(Value) ->
escape(Value);
- _ when is_atom(Value) ->
+ Value when is_atom(Value) ->
io_lib:format("~s", [Value]);
- _ ->
+ Value ->
io_lib:format("~w", [Value])
end.
diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl
index d91975359a..b1cc4d028f 100644
--- a/src/rabbit_multi.erl
+++ b/src/rabbit_multi.erl
@@ -114,12 +114,13 @@ action(status, [], RpcTimeout) ->
io:format("Status of all running nodes...~n", []),
call_all_nodes(
fun({Node, Pid}) ->
- Status = rpc:call(Node, rabbit, status, [], RpcTimeout),
+ RabbitRunning =
+ case is_rabbit_running(Node, RpcTimeout) of
+ false -> not_running;
+ true -> running
+ end,
io:format("Node '~p' with Pid ~p: ~p~n",
- [Node, Pid, case parse_status(Status) of
- false -> not_running;
- true -> running
- end])
+ [Node, Pid, RabbitRunning])
end);
action(stop_all, [], RpcTimeout) ->
@@ -197,7 +198,7 @@ start_node(NodeName, NodePort, RpcTimeout) ->
wait_for_rabbit_to_start(_ , RpcTimeout, _) when RpcTimeout < 0 ->
false;
wait_for_rabbit_to_start(Node, RpcTimeout, Port) ->
- case parse_status(rpc:call(Node, rabbit, status, [])) of
+ case is_rabbit_running(Node, RpcTimeout) of
true -> true;
false -> receive
{'EXIT', Port, PosixCode} ->
@@ -211,22 +212,20 @@ wait_for_rabbit_to_start(Node, RpcTimeout, Port) ->
run_cmd(FullPath) ->
erlang:open_port({spawn, FullPath}, [nouse_stdio]).
-parse_status({badrpc, _}) ->
- false;
-
-parse_status(Status) ->
- case lists:keysearch(running_applications, 1, Status) of
- {value, {running_applications, Apps}} ->
- lists:keymember(rabbit, 1, Apps);
- _ ->
- false
+is_rabbit_running(Node, RpcTimeout) ->
+ case rpc:call(Node, rabbit, status, [], RpcTimeout) of
+ {badrpc, _} -> false;
+ Status -> case proplists:get_value(running_applications, Status) of
+ undefined -> false;
+ Apps -> lists:keymember(rabbit, 1, Apps)
+ end
end.
with_os(Handlers) ->
{OsFamily, _} = os:type(),
- case lists:keysearch(OsFamily, 1, Handlers) of
- {value, {_, Handler}} -> Handler();
- false -> throw({unsupported_os, OsFamily})
+ case proplists:get_value(OsFamily, Handlers) of
+ undefined -> throw({unsupported_os, OsFamily});
+ Handler -> Handler()
end.
script_filename() ->
diff --git a/src/rabbit_plugin_activator.erl b/src/rabbit_plugin_activator.erl
index 71278bfb2a..0206f73e9f 100644
--- a/src/rabbit_plugin_activator.erl
+++ b/src/rabbit_plugin_activator.erl
@@ -68,7 +68,7 @@ start() ->
AppList
end,
AppVersions = [determine_version(App) || App <- AllApps],
- {value, {rabbit, RabbitVersion}} = lists:keysearch(rabbit, 1, AppVersions),
+ {rabbit, RabbitVersion} = proplists:lookup(rabbit, AppVersions),
%% Build the overall release descriptor
RDesc = {release,