From 0639aba42ad8449fe43eb2aad0ffbe3390aabd37 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Sun, 16 Jan 2022 02:11:04 +0100 Subject: scripted-diff: rename `cs_SubVer` -> `m_subver_mutex` -BEGIN VERIFY SCRIPT- sed -i 's/cs_SubVer/m_subver_mutex/g' ./src/net.h ./src/net.cpp ./src/net_processing.cpp -END VERIFY SCRIPT- --- src/net.cpp | 2 +- src/net.h | 4 ++-- src/net_processing.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 89a4aee5d9..7b8a87f90c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -595,7 +595,7 @@ void CNode::CopyStats(CNodeStats& stats) X(m_addr_name); X(nVersion); { - LOCK(cs_SubVer); + LOCK(m_subver_mutex); X(cleanSubVer); } stats.fInbound = IsInboundConn(); diff --git a/src/net.h b/src/net.h index 80fc93a5d0..14c94c0319 100644 --- a/src/net.h +++ b/src/net.h @@ -434,12 +434,12 @@ public: //! Whether this peer is an inbound onion, i.e. connected via our Tor onion service. const bool m_inbound_onion; std::atomic nVersion{0}; - RecursiveMutex cs_SubVer; + RecursiveMutex m_subver_mutex; /** * cleanSubVer is a sanitized string of the user agent byte array we read * from the wire. This cleaned string can safely be logged or displayed. */ - std::string cleanSubVer GUARDED_BY(cs_SubVer){}; + std::string cleanSubVer GUARDED_BY(m_subver_mutex){}; bool m_prefer_evict{false}; // This peer is preferred for eviction. bool HasPermission(NetPermissionFlags permission) const { return NetPermissions::HasFlag(m_permissionFlags, permission); diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 5bff29c097..273cb4fccb 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2636,7 +2636,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, pfrom.nServices = nServices; pfrom.SetAddrLocal(addrMe); { - LOCK(pfrom.cs_SubVer); + LOCK(pfrom.m_subver_mutex); pfrom.cleanSubVer = cleanSubVer; } peer->m_starting_height = starting_height; -- cgit v1.2.3 From 30927cb5306d01da2716786c2d9457c49ec49d0f Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Sun, 16 Jan 2022 02:14:12 +0100 Subject: refactor: replace RecursiveMutex `m_subver_mutex` with Mutex In each of the critical sections, only the the guarded variable is accessed, without any chance that within one section another one is called. Hence, we can use an ordinary Mutex instead of RecursiveMutex. --- src/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.h b/src/net.h index 14c94c0319..c79abb91c3 100644 --- a/src/net.h +++ b/src/net.h @@ -434,7 +434,7 @@ public: //! Whether this peer is an inbound onion, i.e. connected via our Tor onion service. const bool m_inbound_onion; std::atomic nVersion{0}; - RecursiveMutex m_subver_mutex; + Mutex m_subver_mutex; /** * cleanSubVer is a sanitized string of the user agent byte array we read * from the wire. This cleaned string can safely be logged or displayed. -- cgit v1.2.3