Skip to content

Commit 4ad4abc

Browse files
committed
[net] Change addr send times fields to be guarded by new mutex
1 parent c02fa47 commit 4ad4abc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/net.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,9 @@ class CNode
548548
std::vector<CAddress> vAddrToSend;
549549
std::unique_ptr<CRollingBloomFilter> m_addr_known{nullptr};
550550
bool fGetAddr{false};
551-
std::chrono::microseconds m_next_addr_send GUARDED_BY(cs_sendProcessing){0};
552-
std::chrono::microseconds m_next_local_addr_send GUARDED_BY(cs_sendProcessing){0};
551+
Mutex m_addr_send_times_mutex;
552+
std::chrono::microseconds m_next_addr_send GUARDED_BY(m_addr_send_times_mutex){0};
553+
std::chrono::microseconds m_next_local_addr_send GUARDED_BY(m_addr_send_times_mutex){0};
553554

554555
struct TxRelay {
555556
mutable RecursiveMutex cs_filter;

src/net_processing.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4189,6 +4189,8 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
41894189
CNodeState &state = *State(pto->GetId());
41904190

41914191
// Address refresh broadcast
4192+
{
4193+
LOCK(pto->m_addr_send_times_mutex);
41924194

41934195
if (fListen && pto->RelayAddrsWithConn() &&
41944196
!m_chainman.ActiveChainstate().IsInitialBlockDownload() &&
@@ -4249,6 +4251,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
42494251
if (pto->vAddrToSend.capacity() > 40)
42504252
pto->vAddrToSend.shrink_to_fit();
42514253
}
4254+
} // pto->m_addr_send_times_mutex
42524255

42534256
// Start block sync
42544257
if (pindexBestHeader == nullptr)

0 commit comments

Comments
 (0)