From e971624d77dcbdc5a97779030b2f6c25ef5c3d05 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 2 Mar 2021 16:31:00 +0800 Subject: [PATCH] crimson/mon: let on_session_opened() return a future so we can expand its responsibility to perform some async calls. Signed-off-by: Kefu Chai --- src/crimson/mon/MonClient.cc | 18 +++++++++++------- src/crimson/mon/MonClient.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/crimson/mon/MonClient.cc b/src/crimson/mon/MonClient.cc index 06c08dfdf12..e5af77e52bd 100644 --- a/src/crimson/mon/MonClient.cc +++ b/src/crimson/mon/MonClient.cc @@ -514,9 +514,10 @@ void Client::ms_handle_reset(crimson::net::ConnectionRef conn, bool /* is_replac active_con.reset(); return reopen_session(-1).then([this] { if (active_con) { - on_session_opened(); + return on_session_opened(); + } else { + return seastar::now(); } - return seastar::now(); }); } else { return seastar::now(); @@ -757,9 +758,10 @@ seastar::future<> Client::handle_monmap(crimson::net::ConnectionRef conn, logger().warn("mon.{} went away", cur_mon); return reopen_session(-1).then([this] { if (active_con) { - on_session_opened(); + return on_session_opened(); + } else { + return seastar::now(); } - return seastar::now(); }); } } @@ -878,9 +880,10 @@ seastar::future<> Client::authenticate() { return reopen_session(-1).then([this] { if (active_con) { - on_session_opened(); + return on_session_opened(); + } else { + return seastar::now(); } - return seastar::now(); }); } @@ -1019,13 +1022,14 @@ seastar::future<> Client::send_message(MessageRef m) } } -void Client::on_session_opened() +seastar::future<> Client::on_session_opened() { for (auto& m : pending_messages) { (void) active_con->get_conn()->send(m.msg); m.pr.set_value(); } pending_messages.clear(); + return seastar::now(); } bool Client::sub_want(const std::string& what, version_t start, unsigned flags) diff --git a/src/crimson/mon/MonClient.h b/src/crimson/mon/MonClient.h index 549b407dc9c..430260c3170 100644 --- a/src/crimson/mon/MonClient.h +++ b/src/crimson/mon/MonClient.h @@ -155,7 +155,7 @@ private: seastar::future<> handle_log_ack(Ref m); seastar::future<> handle_config(Ref m); - void on_session_opened(); + seastar::future<> on_session_opened(); private: seastar::future<> load_keyring(); seastar::future<> authenticate(); -- 2.39.5