From de4b4bf9ee9841a8c2b0153378022a772d0e2de6 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:00:59 +0000 Subject: [PATCH] merge bitcoin#24108: Replace RecursiveMutex cs_addrLocal with Mutex, and rename it --- src/net.cpp | 6 ++++-- src/net.h | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 9b57c8ffab..22c6b8d5ee 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -606,12 +606,14 @@ std::string ConnectionTypeAsString(ConnectionType conn_type) CService CNode::GetAddrLocal() const { - LOCK(cs_addrLocal); + AssertLockNotHeld(m_addr_local_mutex); + LOCK(m_addr_local_mutex); return addrLocal; } void CNode::SetAddrLocal(const CService& addrLocalIn) { - LOCK(cs_addrLocal); + AssertLockNotHeld(m_addr_local_mutex); + LOCK(m_addr_local_mutex); if (addrLocal.IsValid()) { error("Addr local already set for node: %i. Refusing to change from %s to %s", id, addrLocal.ToString(), addrLocalIn.ToString()); } else { diff --git a/src/net.h b/src/net.h index fdf49e060e..2d463c1965 100644 --- a/src/net.h +++ b/src/net.h @@ -664,9 +664,9 @@ public: return m_greatest_common_version; } - CService GetAddrLocal() const; + CService GetAddrLocal() const LOCKS_EXCLUDED(m_addr_local_mutex); //! May not be called more than once - void SetAddrLocal(const CService& addrLocalIn); + void SetAddrLocal(const CService& addrLocalIn) LOCKS_EXCLUDED(m_addr_local_mutex); CNode* AddRef() { @@ -766,8 +766,8 @@ private: std::list vRecvMsg; // Used only by SocketHandler thread // Our address, as reported by the peer - CService addrLocal GUARDED_BY(cs_addrLocal); - mutable RecursiveMutex cs_addrLocal; + CService addrLocal GUARDED_BY(m_addr_local_mutex); + mutable Mutex m_addr_local_mutex; // Challenge sent in VERSION to be answered with MNAUTH (only happens between MNs) mutable Mutex cs_mnauth;