Skip to content

Commit b32f0d3

Browse files
author
MarcoFalke
committed
Merge bitcoin#24108: Replace RecursiveMutex cs_addrLocal with Mutex, and rename it
dec787d refactor: replace RecursiveMutex `m_addr_local_mutex` with Mutex (w0xlt) 93609c1 p2p: add assertions and negative TS annotations for m_addr_local_mutex (w0xlt) c4a31ca scripted-diff: rename cs_addrLocal -> m_addr_local_mutex (w0xlt) Pull request description: This PR is related to bitcoin#19303 and gets rid of the `RecursiveMutex cs_addrLocal`. ACKs for top commit: hebasto: ACK dec787d, I have reviewed the code and it looks OK, I agree it can be merged. shaavan: reACK dec787d Tree-SHA512: b7a043bfd4e2ccbe313bff21ad815169db6ad215ca96daf358ce960c496a548b4a9e90be9e4357430ca59652b96df87c097450118996c6d4703cbaabde2072d0
2 parents b3122e1 + dec787d commit b32f0d3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/net.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,14 @@ std::string ConnectionTypeAsString(ConnectionType conn_type)
553553

554554
CService CNode::GetAddrLocal() const
555555
{
556-
LOCK(cs_addrLocal);
556+
AssertLockNotHeld(m_addr_local_mutex);
557+
LOCK(m_addr_local_mutex);
557558
return addrLocal;
558559
}
559560

560561
void CNode::SetAddrLocal(const CService& addrLocalIn) {
561-
LOCK(cs_addrLocal);
562+
AssertLockNotHeld(m_addr_local_mutex);
563+
LOCK(m_addr_local_mutex);
562564
if (addrLocal.IsValid()) {
563565
error("Addr local already set for node: %i. Refusing to change from %s to %s", id, addrLocal.ToString(), addrLocalIn.ToString());
564566
} else {

src/net.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,9 @@ class CNode
618618
return m_greatest_common_version;
619619
}
620620

621-
CService GetAddrLocal() const;
621+
CService GetAddrLocal() const LOCKS_EXCLUDED(m_addr_local_mutex);
622622
//! May not be called more than once
623-
void SetAddrLocal(const CService& addrLocalIn);
623+
void SetAddrLocal(const CService& addrLocalIn) LOCKS_EXCLUDED(m_addr_local_mutex);
624624

625625
CNode* AddRef()
626626
{
@@ -693,8 +693,8 @@ class CNode
693693
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
694694

695695
// Our address, as reported by the peer
696-
CService addrLocal GUARDED_BY(cs_addrLocal);
697-
mutable RecursiveMutex cs_addrLocal;
696+
CService addrLocal GUARDED_BY(m_addr_local_mutex);
697+
mutable Mutex m_addr_local_mutex;
698698

699699
mapMsgCmdSize mapSendBytesPerMsgCmd GUARDED_BY(cs_vSend);
700700
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);

0 commit comments

Comments
 (0)