diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-11-20 15:34:52 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-11-20 15:34:52 +0000 |
commit | ee2823b168f8b8ef85245afd9fc2da60e34055a7 (patch) | |
tree | b173f8b0f6a8a4fff8d56e0a49bc28c5f8e2a80a | |
parent | 7ce22dd3160e8ddd0d14fc1df2fbcd8c6275f5c1 (diff) | |
parent | dffaad46be4d2a7f4af50e387868f3a38d27b3e1 (diff) | |
download | rabbitmq-server-ee2823b168f8b8ef85245afd9fc2da60e34055a7.tar.gz |
stable to default
-rw-r--r-- | src/rabbit_cli.erl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/rabbit_cli.erl b/src/rabbit_cli.erl index 2981f3b2..3fc32039 100644 --- a/src/rabbit_cli.erl +++ b/src/rabbit_cli.erl @@ -57,7 +57,10 @@ main(ParseFun, DoFun, UsageMod) -> %% The reason we don't use a try/catch here is that rpc:call turns %% thrown errors into normal return values - case catch DoFun(Command, Node, Args, Opts) of + case catch begin + sync_ticktime(Node), + DoFun(Command, Node, Args, Opts) + end of ok -> rabbit_misc:quit(0); {'EXIT', {function_clause, [{?MODULE, action, _} | _]}} -> %% < R15 @@ -185,3 +188,12 @@ print_error(Format, Args) -> fmt_stderr("Error: " ++ Format, Args). print_badrpc_diagnostics(Nodes) -> fmt_stderr(rabbit_nodes:diagnostics(Nodes), []). +%% If the server we are talking to has non-standard net_ticktime, and +%% our conncetion lasts a while, we could get disconnected because of +%% a timeout unless we set our ticktime to be the same. So let's do +%% that. +sync_ticktime(Node) -> + case rpc:call(Node, net_kernel, get_net_ticktime, []) of + {badrpc, _} = E -> throw(E); %% To be caught in main/3 + Time -> net_kernel:set_net_ticktime(Time, 0) + end. |