]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/AsyncConnection: optimize check loopback connection. 26923/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Tue, 19 Mar 2019 08:51:07 +0000 (16:51 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Tue, 19 Mar 2019 08:52:29 +0000 (16:52 +0800)
Add bool is_loopback to avoid checking addrs when send_message.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/msg/Connection.h
src/msg/async/AsyncConnection.cc
src/msg/async/AsyncMessenger.h

index 4eea5ff0d6c1824f7c6323075d6237bcbd4a66a6..b852529424dc267bf37b33d248208d73bec5df08 100644 (file)
@@ -53,6 +53,7 @@ struct Connection : public RefCountedObject {
 private:
   uint64_t features;
 public:
+  bool is_loopback;
   bool failed; // true if we are a lossy connection that has failed.
 
   int rx_buffers_version;
@@ -81,6 +82,7 @@ public:
       msgr(m),
       peer_type(-1),
       features(0),
+      is_loopback(false),
       failed(false),
       rx_buffers_version(0) {
   }
index 91ea1f6c82786b03039ae13ffce927158fb810f2..d1c7e6016a61ad48dfcad0fade931fcb6b0c56e7 100644 (file)
@@ -516,7 +516,7 @@ int AsyncConnection::send_message(Message *m)
   else if (m->get_type() == CEPH_MSG_OSD_OPREPLY)
     OID_EVENT_TRACE_WITH_MSG(m, "SEND_MSG_OSD_OPREPLY_BEGIN", true);
 
-  if (async_msgr->get_myaddrs() == get_peer_addrs()) { //loopback connection
+  if (is_loopback) { //loopback connection
     ldout(async_msgr->cct, 20) << __func__ << " " << *m << " local" << dendl;
     std::lock_guard<std::mutex> l(write_lock);
     if (protocol->is_connected()) {
index f13e30c0b962da252a212f34dbe138231f5151ad..2bc7b876f9b7b4d3bf7c91bb7fc89b435bb3c9e0 100644 (file)
@@ -392,6 +392,7 @@ public:
    */
   void init_local_connection() {
     Mutex::Locker l(lock);
+    local_connection->is_loopback = true;
     _init_local_connection();
   }