}
}
-void MDSDaemon::send_command_reply(const cref_t<MCommand> &m, MDSRank *mds_rank,
- int r, bufferlist outbl,
- std::string_view outs)
-{
- auto priv = m->get_connection()->get_priv();
- auto session = static_cast<Session *>(priv.get());
- ceph_assert(session != NULL);
- // If someone is using a closed session for sending commands (e.g.
- // the ceph CLI) then we should feel free to clean up this connection
- // as soon as we've sent them a response.
- const bool live_session =
- session->get_state_seq() > 0 &&
- mds_rank &&
- mds_rank->sessionmap.get_session(session->info.inst.name);
-
- if (!live_session) {
- // This session only existed to issue commands, so terminate it
- // as soon as we can.
- ceph_assert(session->is_closed());
- session->get_connection()->mark_disposable();
- }
- priv.reset();
-
- auto reply = make_message<MCommandReply>(r, outs);
- reply->set_tid(m->get_tid());
- reply->set_data(outbl);
- m->get_connection()->send_message2(reply);
-}
-
void MDSDaemon::handle_command(const cref_t<MCommand> &m)
{
auto priv = m->get_connection()->get_priv();
cct->get_admin_socket()->queue_tell_command(m);
return;
}
+
+ // If someone is using a closed session for sending commands (e.g.
+ // the ceph CLI) then we should feel free to clean up this connection
+ // as soon as we've sent them a response.
+ const bool live_session =
+ session->get_state_seq() > 0 &&
+ mds_rank &&
+ mds_rank->sessionmap.get_session(session->info.inst.name);
+
+ if (!live_session) {
+ // This session only existed to issue commands, so terminate it
+ // as soon as we can.
+ ceph_assert(session->is_closed());
+ session->get_connection()->mark_disposable();
+ }
priv.reset();
- send_command_reply(m, mds_rank, r, outbl, outs);
+ auto reply = make_message<MCommandReply>(r, outs);
+ reply->set_tid(m->get_tid());
+ reply->set_data(outbl);
+ m->get_connection()->send_message2(reply);
}
const std::vector<MDSDaemon::MDSCommand>& MDSDaemon::get_commands()
on_finish(r, ss.str(), outbl);
}
-class C_MDS_Send_Command_Reply : public MDSInternalContext {
-protected:
- cref_t<MCommand> m;
-public:
- C_MDS_Send_Command_Reply(MDSRank *_mds, const cref_t<MCommand> &_m) :
- MDSInternalContext(_mds), m(_m) {}
-
- void send(int r, std::string_view ss) {
- std::stringstream ds;
- send(r, ss, ds);
- }
-
- void send(int r, std::string_view ss, std::stringstream &ds) {
- bufferlist bl;
- bl.append(ds);
- MDSDaemon::send_command_reply(m, mds, r, bl, ss);
- }
-
- void finish(int r) override {
- send(r, "");
- }
-};
-
/**
* This function drops the mds_lock, so don't do anything with
* MDSRank after calling it (we could have gone into shutdown): just