From 90e0ef907fce2ef7a196cd256ab970c8eb5d9e57 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 31 Jul 2012 14:47:26 -0700 Subject: [PATCH] cephtool: retry 'ceph tell ...' command if connection fails It was easy to reproduce a hang with 'ceph osd tell osd.0 foo' and messenger failure injection. Signed-off-by: Sage Weil --- src/tools/common.cc | 16 +++++++++++++++- src/tools/common.h | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tools/common.cc b/src/tools/common.cc index 78ab62b5081d8..4c671c7cd83ea 100644 --- a/src/tools/common.cc +++ b/src/tools/common.cc @@ -160,7 +160,8 @@ static void send_command(CephToolCtx *ctx) if (!ctx->concise) *ctx->log << ceph_clock_now(g_ceph_context) << " " << pending_target << " <- " << pending_cmd << std::endl; - messenger->send_message(m, osdmap->get_inst(n)); + command_con = messenger->get_connection(osdmap->get_inst(n)); + messenger->send_message(m, command_con); } return; } @@ -553,6 +554,19 @@ void Admin::ms_handle_connect(Connection *con) { } } +bool Admin::ms_handle_reset(Connection *con) +{ + Mutex::Locker l(ctx->lock); + if (con == command_con) { + command_con->put(); + command_con = NULL; + if (pending_cmd.size()) + send_command(ctx); + return true; + } + return false; +} + bool Admin::ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer, bool force_new) { diff --git a/src/tools/common.h b/src/tools/common.h index a0bad8a30a369..93a7d4a127095 100644 --- a/src/tools/common.h +++ b/src/tools/common.h @@ -63,7 +63,7 @@ public: bool ms_dispatch(Message *m); void ms_handle_connect(Connection *con); - bool ms_handle_reset(Connection *con) { return false; } + bool ms_handle_reset(Connection *con); void ms_handle_remote_reset(Connection *con) {} bool ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer, bool force_new); -- 2.39.5