summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexey Lebedeff <alebedev@mirantis.com>2016-07-13 18:15:04 +0300
committerAlexey Lebedeff <alebedev@mirantis.com>2016-07-14 13:39:17 +0300
commit7b36b7ff75d5d7cea98b40690fd7b19c983b9c5c (patch)
tree43a466339d1d7798552af6441fd91eae555e4824 /src
parent3448f97e0ab6c6978066f937a14d467ad9b2d6ca (diff)
downloadrabbitmq-server-git-7b36b7ff75d5d7cea98b40690fd7b19c983b9c5c.tar.gz
Default timeouts: fix global/add per-command
- Global timeout `?RPC_TIMEOUT` was not used, because default value of infinity was always introduced via `?TIMEOUT_DEF`. Now `infinity` is used for commands without timeout support, and `?RPC_TIMEOUT` otherwise. - `?COMMANDS_WITH_TIMEOUT` now can contain per-command default values for timeout, using tuple `{Command, DefaultTimeoutInMilliSeconds}` instead of just `Command`.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_control_main.erl28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl
index fb3da21287..55839d34e0 100644
--- a/src/rabbit_control_main.erl
+++ b/src/rabbit_control_main.erl
@@ -116,6 +116,7 @@
forget_cluster_node, rename_cluster_node, cluster_status, status,
environment, eval, force_boot, help, node_health_check, hipe_compile]).
+%% [Command | {Command, DefaultTimeoutInMilliSeconds}]
-define(COMMANDS_WITH_TIMEOUT,
[list_user_permissions, list_policies, list_queues, list_exchanges,
list_bindings, list_connections, list_channels, list_consumers,
@@ -152,7 +153,7 @@ start() ->
end
end,
try
- T = case get_timeout(Opts) of
+ T = case get_timeout(Command, Opts) of
{ok, Timeout} ->
Timeout;
{error, _} ->
@@ -187,8 +188,23 @@ print_report0(Node, {Module, InfoFun, KeysFun}, VHostArg) ->
end,
io:nl().
-get_timeout(Opts) ->
- parse_timeout(proplists:get_value(?TIMEOUT_OPT, Opts, ?RPC_TIMEOUT)).
+get_timeout(Command, Opts) ->
+ Default = case proplists:lookup(Command, ?COMMANDS_WITH_TIMEOUT) of
+ none ->
+ infinity;
+ {Command, true} ->
+ ?RPC_TIMEOUT;
+ {Command, D} ->
+ D
+ end,
+ Result = case proplists:get_value(?TIMEOUT_OPT, Opts, Default) of
+ use_default ->
+ parse_timeout(Default);
+ Value ->
+ parse_timeout(Value)
+ end,
+ Result.
+
parse_number(N) when is_list(N) ->
try list_to_integer(N) of
@@ -234,11 +250,11 @@ do_action(Command, Node, Args, Opts, Inform, Timeout) ->
false ->
case ensure_app_running(Node) of
ok ->
- case lists:member(Command, ?COMMANDS_WITH_TIMEOUT) of
- true ->
+ case proplists:lookup(Command, ?COMMANDS_WITH_TIMEOUT) of
+ {Command, _} ->
announce_timeout(Timeout, Inform),
action(Command, Node, Args, Opts, Inform, Timeout);
- false ->
+ none ->
action(Command, Node, Args, Opts, Inform)
end;
E -> E