Skip to content

Commit 93609c1

Browse files
committed
p2p: add assertions and negative TS annotations for m_addr_local_mutex
1 parent c4a31ca commit 93609c1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/net.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,13 @@ std::string ConnectionTypeAsString(ConnectionType conn_type)
553553

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

560561
void CNode::SetAddrLocal(const CService& addrLocalIn) {
562+
AssertLockNotHeld(m_addr_local_mutex);
561563
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());

src/net.h

Lines changed: 2 additions & 2 deletions
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
{

0 commit comments

Comments
 (0)