From: Max Kellermann Date: Fri, 15 Aug 2025 17:02:57 +0000 (+0200) Subject: mon/Monitor: forward-declare class MMonCommand X-Git-Tag: v21.0.0~50^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b8f220091aec33d5cef01d3e842c8142764d6dcd;p=ceph.git mon/Monitor: forward-declare class MMonCommand Signed-off-by: Max Kellermann --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 198b58a2266..7a3f0492151 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -39,6 +39,7 @@ #include "MonitorDBStore.h" #include "messages/PaxosServiceMessage.h" +#include "messages/MMonCommand.h" #include "messages/MMonMap.h" #include "messages/MMonGetMap.h" #include "messages/MMonGetVersion.h" @@ -146,6 +147,42 @@ static ostream& _prefix(std::ostream *_dout, const Monitor *mon) { << "(" << mon->get_state_name() << ") e" << mon->monmap->get_epoch() << " "; } +void Monitor::C_Command::_finish(int r) { + auto m = op->get_req(); + if (r >= 0) { + std::ostringstream ss; + if (!op->get_req()->get_connection()) { + ss << "connection dropped for command "; + } else { + MonSession *s = op->get_session(); + + // if client drops we may not have a session to draw information from. + if (s) { + ss << "from='" << s->name << " " << s->addrs << "' " + << "entity='" << s->entity_name << "' "; + } else { + ss << "session dropped for command "; + } + } + cmdmap_t cmdmap; + std::ostringstream ds; + std::string prefix; + cmdmap_from_json(m->cmd, &cmdmap, ds); + cmd_getval(cmdmap, "prefix", prefix); + if (prefix != "config set" && prefix != "config-key set") + ss << "cmd='" << m->cmd << "': finished"; + + mon.audit_clog->info() << ss.str(); + mon.reply_command(op, rc, rs, rdata, version); + } + else if (r == -ECANCELED) + return; + else if (r == -EAGAIN) + mon.dispatch_op(op); + else + ceph_abort_msg("bad C_Command return value"); +} + const string Monitor::MONITOR_NAME = "monitor"; const string Monitor::MONITOR_STORE_PREFIX = "monitor_store"; diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 2830e0ef8b0..43d90443a24 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -49,7 +49,6 @@ #include "auth/AuthMethodList.h" #include "auth/KeyRing.h" #include "include/common_fwd.h" -#include "messages/MMonCommand.h" #include "mon/MonitorDBStore.h" #include "mgr/MgrClient.h" #include @@ -913,41 +912,7 @@ public: C_Command(Monitor &_mm, MonOpRequestRef _op, int r, std::string s, ceph::buffer::list rd, version_t v) : C_MonOp(_op), mon(_mm), rc(r), rs(s), rdata(rd), version(v){} - void _finish(int r) override { - auto m = op->get_req(); - if (r >= 0) { - std::ostringstream ss; - if (!op->get_req()->get_connection()) { - ss << "connection dropped for command "; - } else { - MonSession *s = op->get_session(); - - // if client drops we may not have a session to draw information from. - if (s) { - ss << "from='" << s->name << " " << s->addrs << "' " - << "entity='" << s->entity_name << "' "; - } else { - ss << "session dropped for command "; - } - } - cmdmap_t cmdmap; - std::ostringstream ds; - std::string prefix; - cmdmap_from_json(m->cmd, &cmdmap, ds); - cmd_getval(cmdmap, "prefix", prefix); - if (prefix != "config set" && prefix != "config-key set") - ss << "cmd='" << m->cmd << "': finished"; - - mon.audit_clog->info() << ss.str(); - mon.reply_command(op, rc, rs, rdata, version); - } - else if (r == -ECANCELED) - return; - else if (r == -EAGAIN) - mon.dispatch_op(op); - else - ceph_abort_msg("bad C_Command return value"); - } + void _finish(int r) override; }; private: