From 4ad4abcf07efefafd439b28679dff8d6bbf62943 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Mon, 29 Mar 2021 11:36:19 +0100 Subject: [PATCH] [net] Change addr send times fields to be guarded by new mutex --- src/net.h | 5 +++-- src/net_processing.cpp | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/net.h b/src/net.h index 5228c4fbd3b..66868be7c8c 100644 --- a/src/net.h +++ b/src/net.h @@ -548,8 +548,9 @@ public: std::vector vAddrToSend; std::unique_ptr m_addr_known{nullptr}; bool fGetAddr{false}; - std::chrono::microseconds m_next_addr_send GUARDED_BY(cs_sendProcessing){0}; - std::chrono::microseconds m_next_local_addr_send GUARDED_BY(cs_sendProcessing){0}; + Mutex m_addr_send_times_mutex; + std::chrono::microseconds m_next_addr_send GUARDED_BY(m_addr_send_times_mutex){0}; + std::chrono::microseconds m_next_local_addr_send GUARDED_BY(m_addr_send_times_mutex){0}; struct TxRelay { mutable RecursiveMutex cs_filter; diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 9f9af0aa33c..359b7d98436 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -4189,6 +4189,8 @@ bool PeerManagerImpl::SendMessages(CNode* pto) CNodeState &state = *State(pto->GetId()); // Address refresh broadcast + { + LOCK(pto->m_addr_send_times_mutex); if (fListen && pto->RelayAddrsWithConn() && !m_chainman.ActiveChainstate().IsInitialBlockDownload() && @@ -4249,6 +4251,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto) if (pto->vAddrToSend.capacity() > 40) pto->vAddrToSend.shrink_to_fit(); } + } // pto->m_addr_send_times_mutex // Start block sync if (pindexBestHeader == nullptr)