]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: make connection check more robust
authorSage Weil <sage@redhat.com>
Wed, 23 May 2018 22:37:00 +0000 (17:37 -0500)
committerSage Weil <sage@redhat.com>
Fri, 25 May 2018 22:54:53 +0000 (17:54 -0500)
Do no rely on the address comparison; just check the Connection*
itself.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MonClient.cc
src/mon/MonClient.h

index 9cf96f20fe1d7dfbe5b4d7f4e957173c7aba1daa..b53ee2fe14b96551a77a9a041e8ea1bf65af3da5 100644 (file)
@@ -271,9 +271,8 @@ bool MonClient::ms_dispatch(Message *m)
   Mutex::Locker lock(monc_lock);
 
   if (_hunting()) {
-    auto pending_con = pending_cons.find(m->get_source_addr());
-    if (pending_con == pending_cons.end() ||
-       pending_con->second.get_con() != m->get_connection()) {
+    auto p = _find_pending_con(m->get_connection());
+    if (p == pending_cons.end()) {
       // ignore any messages outside hunting sessions
       ldout(cct, 10) << "discarding stray monitor message " << *m << dendl;
       m->put();
@@ -541,7 +540,7 @@ void MonClient::handle_auth(MAuthReply *m)
   }
 
   // hunting
-  auto found = pending_cons.find(m->get_source_addr());
+  auto found = _find_pending_con(m->get_connection());
   assert(found != pending_cons.end());
   int auth_err = found->second.handle_auth(m, entity_name, want_keys,
                                           rotating_secrets.get());
index 688f13c91ce0daf6f60daff26f4a6ca3efba8279..dca43693a0fb8c75424e8285c22148547080d2b3 100644 (file)
@@ -216,6 +216,16 @@ private:
   void _add_conns(uint64_t global_id);
   void _send_mon_message(Message *m);
 
+  std::map<entity_addr_t, MonConnection>::iterator _find_pending_con(
+    const ConnectionRef& con) {
+    for (auto i = pending_cons.begin(); i != pending_cons.end(); ++i) {
+      if (i->second.get_con() == con) {
+       return i;
+      }
+    }
+    return pending_cons.end();
+  }
+
 public:
   void set_entity_name(EntityName name) { entity_name = name; }