diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-11-20 15:33:38 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-11-20 15:33:38 +0000 |
commit | dd7691db091e2cab7f059515b66d054bbd911d44 (patch) | |
tree | 3fa8fa3356e99ff379426944192800da63305c7e | |
parent | 58637f1f49476dbd7eedd1baac1ab1857b329f52 (diff) | |
download | rabbitmq-server-dd7691db091e2cab7f059515b66d054bbd911d44.tar.gz |
Sync ticktime with server.
-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. |