From 2db037474f42eb094aa16b63f1dfdf4acd7da172 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Tue, 19 Mar 2019 16:51:07 +0800 Subject: [PATCH] msg/async/AsyncConnection: optimize check loopback connection. Add bool is_loopback to avoid checking addrs when send_message. Signed-off-by: Jianpeng Ma --- src/msg/Connection.h | 2 ++ src/msg/async/AsyncConnection.cc | 2 +- src/msg/async/AsyncMessenger.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/msg/Connection.h b/src/msg/Connection.h index 4eea5ff0d6c..b852529424d 100644 --- a/src/msg/Connection.h +++ b/src/msg/Connection.h @@ -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) { } diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index 91ea1f6c827..d1c7e6016a6 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -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 l(write_lock); if (protocol->is_connected()) { diff --git a/src/msg/async/AsyncMessenger.h b/src/msg/async/AsyncMessenger.h index f13e30c0b96..2bc7b876f9b 100644 --- a/src/msg/async/AsyncMessenger.h +++ b/src/msg/async/AsyncMessenger.h @@ -392,6 +392,7 @@ public: */ void init_local_connection() { Mutex::Locker l(lock); + local_connection->is_loopback = true; _init_local_connection(); } -- 2.39.5