Skip to content

Commit de4b4bf

Browse files
committed
merge bitcoin#24108: Replace RecursiveMutex cs_addrLocal with Mutex, and rename it
1 parent 2f7a138 commit de4b4bf

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/net.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,14 @@ std::string ConnectionTypeAsString(ConnectionType conn_type)
606606

607607
CService CNode::GetAddrLocal() const
608608
{
609-
LOCK(cs_addrLocal);
609+
AssertLockNotHeld(m_addr_local_mutex);
610+
LOCK(m_addr_local_mutex);
610611
return addrLocal;
611612
}
612613

613614
void CNode::SetAddrLocal(const CService& addrLocalIn) {
614-
LOCK(cs_addrLocal);
615+
AssertLockNotHeld(m_addr_local_mutex);
616+
LOCK(m_addr_local_mutex);
615617
if (addrLocal.IsValid()) {
616618
error("Addr local already set for node: %i. Refusing to change from %s to %s", id, addrLocal.ToString(), addrLocalIn.ToString());
617619
} else {

src/net.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,9 @@ class CNode
664664
return m_greatest_common_version;
665665
}
666666

667-
CService GetAddrLocal() const;
667+
CService GetAddrLocal() const LOCKS_EXCLUDED(m_addr_local_mutex);
668668
//! May not be called more than once
669-
void SetAddrLocal(const CService& addrLocalIn);
669+
void SetAddrLocal(const CService& addrLocalIn) LOCKS_EXCLUDED(m_addr_local_mutex);
670670

671671
CNode* AddRef()
672672
{
@@ -766,8 +766,8 @@ class CNode
766766
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
767767

768768
// Our address, as reported by the peer
769-
CService addrLocal GUARDED_BY(cs_addrLocal);
770-
mutable RecursiveMutex cs_addrLocal;
769+
CService addrLocal GUARDED_BY(m_addr_local_mutex);
770+
mutable Mutex m_addr_local_mutex;
771771

772772
// Challenge sent in VERSION to be answered with MNAUTH (only happens between MNs)
773773
mutable Mutex cs_mnauth;

0 commit comments

Comments
 (0)