From: Amnon Hanuhov Date: Tue, 27 Apr 2021 09:31:30 +0000 (+0300) Subject: crimson/mon: Refactor mon::send_message() to take unique_ptr X-Git-Tag: v17.1.0~2024^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ade9dc93c4890790e91232e916fac23ff4cf4a36;p=ceph-ci.git crimson/mon: Refactor mon::send_message() to take unique_ptr Signed-off-by: Amnon Hanuhov --- diff --git a/src/crimson/mon/MonClient.cc b/src/crimson/mon/MonClient.cc index 2628998eb4a..08c34debc44 100644 --- a/src/crimson/mon/MonClient.cc +++ b/src/crimson/mon/MonClient.cc @@ -798,12 +798,12 @@ seastar::future<> Client::handle_subscribe_ack(Ref m) Client::get_version_t Client::get_version(const std::string& map) { - auto m = make_message(); + auto m = crimson::net::make_message(); auto tid = ++last_version_req_id; m->handle = tid; m->what = map; auto& req = version_reqs[tid]; - return send_message(m).then([&req] { + return send_message(std::move(m)).then([&req] { return req.get_future(); }); } @@ -1013,7 +1013,7 @@ Client::command_result_t Client::run_command(std::string&& cmd, bufferlist&& bl) { - auto m = make_message(monmap.fsid); + auto m = crimson::net::make_message(monmap.fsid); auto tid = ++last_mon_command_id; m->set_tid(tid); m->cmd = {std::move(cmd)}; @@ -1024,13 +1024,13 @@ Client::run_command(std::string&& cmd, }); } -seastar::future<> Client::send_message(MessageRef m) +seastar::future<> Client::send_message(MessageURef m) { if (active_con) { assert(pending_messages.empty()); - return active_con->get_conn()->send(m); + return active_con->get_conn()->send(std::move(m)); } else { - auto& delayed = pending_messages.emplace_back(m); + auto& delayed = pending_messages.emplace_back(std::move(m)); return delayed.pr.get_future(); } } @@ -1041,7 +1041,7 @@ seastar::future<> Client::on_session_opened() return sub.reload() ? renew_subs() : seastar::now(); }).then([this] { for (auto& m : pending_messages) { - (void) active_con->get_conn()->send(m.msg); + (void) active_con->get_conn()->send(std::move(m.msg)); m.pr.set_value(); } pending_messages.clear(); @@ -1049,7 +1049,7 @@ seastar::future<> Client::on_session_opened() }).then([this] { return seastar::parallel_for_each(mon_commands, [this](auto &command) { - return send_message(make_message(*command.req)); + return send_message(crimson::net::make_message(*command.req)); }); }); } @@ -1084,10 +1084,10 @@ seastar::future<> Client::renew_subs() } logger().trace("{}", __func__); - auto m = make_message(); + auto m = crimson::net::make_message(); m->what = sub.get_subs(); m->hostname = ceph_get_short_hostname(); - return send_message(m).then([this] { + return send_message(std::move(m)).then([this] { sub.renewed(); }); } diff --git a/src/crimson/mon/MonClient.h b/src/crimson/mon/MonClient.h index 9ae4d2a79e8..d1f590f429c 100644 --- a/src/crimson/mon/MonClient.h +++ b/src/crimson/mon/MonClient.h @@ -91,7 +91,7 @@ public: get_version_t get_version(const std::string& map); command_result_t run_command(std::string&& cmd, bufferlist&& bl); - seastar::future<> send_message(MessageRef); + seastar::future<> send_message(MessageURef); bool sub_want(const std::string& what, version_t start, unsigned flags); void sub_got(const std::string& what, version_t have); void sub_unwant(const std::string& what); @@ -180,8 +180,8 @@ private: // messages that are waiting for the active_con to be available struct pending_msg_t { - pending_msg_t(MessageRef& m) : msg(m) {} - MessageRef msg; + pending_msg_t(MessageURef m) : msg(std::move(m)) {} + MessageURef msg; seastar::promise<> pr; }; std::deque pending_messages;