]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/mon: check for active_con before calling send_pendings()
authorKefu Chai <kchai@redhat.com>
Tue, 2 Mar 2021 08:07:25 +0000 (16:07 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 2 Mar 2021 11:04:28 +0000 (19:04 +0800)
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 <kchai@redhat.com>
src/crimson/mon/MonClient.cc

index 9340ce2b4eefdf6f4dd828ff02148a638aee7d99..3baf5f9fbf1588f9b578414c54a49dae6ac742f6 100644 (file)
@@ -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<unsigned> 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)