summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-11-20 15:34:52 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-11-20 15:34:52 +0000
commitbef9a347a44d6521290d8368f2ea5e21932876f6 (patch)
treeb173f8b0f6a8a4fff8d56e0a49bc28c5f8e2a80a
parentfc1d49108d1561cc7d2db25b9a489c9a4f05fb73 (diff)
parent3142c3fd0d311284625888fb839dc2f2c78424cc (diff)
downloadrabbitmq-server-git-bef9a347a44d6521290d8368f2ea5e21932876f6.tar.gz
stable to default
-rw-r--r--src/rabbit_cli.erl14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/rabbit_cli.erl b/src/rabbit_cli.erl
index 2981f3b2ce..3fc32039a9 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.