From: Sage Weil Date: Sun, 26 Feb 2017 19:09:18 +0000 (-0500) Subject: mgr/MgrClient: resend pending commands on reconnect X-Git-Tag: v12.0.2~252^2~57 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e19d4a0118f4e640d756bb76e854da9570adbe56;p=ceph.git mgr/MgrClient: resend pending commands on reconnect Signed-off-by: Sage Weil --- diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index d18160ba4e0e..e1e0a0c1636a 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -91,19 +91,6 @@ void MgrClient::reconnect() timer.cancel_event(report_callback); report_callback = nullptr; } - - std::vector erase_cmds; - auto commands = command_table.get_commands(); - for (const auto &i : commands) { - // FIXME be nicer, retarget command on new mgr? - if (i.second.on_finish != nullptr) { - i.second.on_finish->complete(-ETIMEDOUT); - } - erase_cmds.push_back(i.first); - } - for (const auto &tid : erase_cmds) { - command_table.erase(tid); - } } if (map.get_available()) { @@ -125,6 +112,13 @@ void MgrClient::reconnect() } signal_cond_list(waiting_for_session); + // resend any pending commands + for (const auto &p : command_table.get_commands()) { + MCommand *m = p.second.get_message({}); + assert(session); + assert(session->con); + session->con->send_message(m); + } } else { ldout(cct, 4) << "No active mgr available yet" << dendl; } @@ -286,11 +280,6 @@ int MgrClient::start_command(const vector& cmd, const bufferlist& inbl, ldout(cct, 20) << "cmd: " << cmd << dendl; - if (!session) { - lderr(cct) << "no session, waiting" << dendl; - wait_on_list(waiting_for_session); - } - assert(map.epoch > 0); auto &op = command_table.start_command(); @@ -300,11 +289,11 @@ int MgrClient::start_command(const vector& cmd, const bufferlist& inbl, op.outs = outs; op.on_finish = onfinish; - // Leaving fsid argument null because it isn't used. - MCommand *m = op.get_message({}); - assert(session); - assert(session->con); - session->con->send_message(m); + if (session && session->con) { + // Leaving fsid argument null because it isn't used. + MCommand *m = op.get_message({}); + session->con->send_message(m); + } return 0; }