From 8c7409eeb83d06ee35756d364ddf6dbb5553ff26 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Thu, 10 Oct 2019 17:59:00 +0800 Subject: [PATCH] msg/async: narrow scope of AsyncMessenger::lock in fun connect_to. In fact, local_connnection init in constructor of AsyncMessenger and never change. So no need protect by AsyncMessenger::lock in AsyncMessenger::connect_to. Signed-off-by: Jianpeng Ma --- src/msg/async/AsyncMessenger.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/msg/async/AsyncMessenger.cc b/src/msg/async/AsyncMessenger.cc index 37c7182f61d..70323ef3da6 100644 --- a/src/msg/async/AsyncMessenger.cc +++ b/src/msg/async/AsyncMessenger.cc @@ -672,7 +672,6 @@ ConnectionRef AsyncMessenger::connect_to(int type, const entity_addrvec_t& addrs, bool anon) { - std::lock_guard l{lock}; if (*my_addrs == addrs || (addrs.v.size() == 1 && my_addrs->contains(addrs.front()))) { @@ -680,6 +679,8 @@ ConnectionRef AsyncMessenger::connect_to(int type, return local_connection; } + std::lock_guard l{lock}; + auto av = _filter_addrs(addrs); if (anon) {