From: Sage Weil Date: Wed, 23 May 2018 22:37:00 +0000 (-0500) Subject: mon/MonClient: make connection check more robust X-Git-Tag: v14.0.1~1271^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2bdab228492bcc71c6ff071b8fe744a2aed6b8a9;p=ceph.git mon/MonClient: make connection check more robust Do no rely on the address comparison; just check the Connection* itself. Signed-off-by: Sage Weil --- diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 9cf96f20fe1d..b53ee2fe14b9 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -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()); diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h index 688f13c91ce0..dca43693a0fb 100644 --- a/src/mon/MonClient.h +++ b/src/mon/MonClient.h @@ -216,6 +216,16 @@ private: void _add_conns(uint64_t global_id); void _send_mon_message(Message *m); + std::map::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; }