From 83d2e322a3a92e57197f2430fb173315a31f0d39 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 2 Mar 2021 16:07:25 +0800 Subject: [PATCH] crimson/mon: check for active_con before calling send_pendings() before this change, we guard the `send_pendings()` call only in `Client::send_message()`, after this change, all of the `send_pendings()` calls are guarded with this check. more consistent this way. Signed-off-by: Kefu Chai --- src/crimson/mon/MonClient.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/crimson/mon/MonClient.cc b/src/crimson/mon/MonClient.cc index 9340ce2b4ee..3baf5f9fbf1 100644 --- a/src/crimson/mon/MonClient.cc +++ b/src/crimson/mon/MonClient.cc @@ -513,7 +513,9 @@ void Client::ms_handle_reset(crimson::net::ConnectionRef conn, bool /* is_replac logger().warn("active conn reset {}", conn->get_peer_addr()); active_con.reset(); return reopen_session(-1).then([this] { - send_pendings(); + if (active_con) { + send_pendings(); + } return seastar::now(); }); } else { @@ -754,7 +756,9 @@ seastar::future<> Client::handle_monmap(crimson::net::ConnectionRef conn, } else { logger().warn("mon.{} went away", cur_mon); return reopen_session(-1).then([this] { - send_pendings(); + if (active_con) { + send_pendings(); + } return seastar::now(); }); } @@ -873,7 +877,9 @@ std::vector Client::get_random_mons(unsigned n) const seastar::future<> Client::authenticate() { return reopen_session(-1).then([this] { - send_pendings(); + if (active_con) { + send_pendings(); + } return seastar::now(); }); } @@ -1016,13 +1022,11 @@ seastar::future<> Client::send_message(MessageRef m) void Client::send_pendings() { - if (active_con) { - for (auto& m : pending_messages) { - (void) active_con->get_conn()->send(m.msg); - m.pr.set_value(); - } - pending_messages.clear(); + for (auto& m : pending_messages) { + (void) active_con->get_conn()->send(m.msg); + m.pr.set_value(); } + pending_messages.clear(); } bool Client::sub_want(const std::string& what, version_t start, unsigned flags) -- 2.47.3