From 60441a3432df10f5d7c15c09c9569f27a793625b Mon Sep 17 00:00:00 2001 From: dergoegge Date: Tue, 14 Mar 2023 18:24:58 +0100 Subject: [PATCH] scripted-diff: [net] Rename CNode process queue members -BEGIN VERIFY SCRIPT- ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); } ren cs_vProcessMsg m_msg_process_queue_mutex ren vProcessMsg m_msg_process_queue ren nProcessQueueSize m_msg_process_queue_size -END VERIFY SCRIPT- --- src/net.cpp | 22 +++++++++++----------- src/net.h | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 80cccb1c74..384db5c014 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2797,7 +2797,7 @@ CNode::CNode(NodeId idIn, void CNode::MarkReceivedMsgsForProcessing(unsigned int recv_flood_size) { - AssertLockNotHeld(cs_vProcessMsg); + AssertLockNotHeld(m_msg_process_queue_mutex); size_t nSizeAdded = 0; for (const auto& msg : vRecvMsg) { @@ -2806,24 +2806,24 @@ void CNode::MarkReceivedMsgsForProcessing(unsigned int recv_flood_size) nSizeAdded += msg.m_raw_message_size; } - LOCK(cs_vProcessMsg); - vProcessMsg.splice(vProcessMsg.end(), vRecvMsg); - nProcessQueueSize += nSizeAdded; - fPauseRecv = nProcessQueueSize > recv_flood_size; + LOCK(m_msg_process_queue_mutex); + m_msg_process_queue.splice(m_msg_process_queue.end(), vRecvMsg); + m_msg_process_queue_size += nSizeAdded; + fPauseRecv = m_msg_process_queue_size > recv_flood_size; } std::optional> CNode::PollMessage(size_t recv_flood_size) { - LOCK(cs_vProcessMsg); - if (vProcessMsg.empty()) return std::nullopt; + LOCK(m_msg_process_queue_mutex); + if (m_msg_process_queue.empty()) return std::nullopt; std::list msgs; // Just take one message - msgs.splice(msgs.begin(), vProcessMsg, vProcessMsg.begin()); - nProcessQueueSize -= msgs.front().m_raw_message_size; - fPauseRecv = nProcessQueueSize > recv_flood_size; + msgs.splice(msgs.begin(), m_msg_process_queue, m_msg_process_queue.begin()); + m_msg_process_queue_size -= msgs.front().m_raw_message_size; + fPauseRecv = m_msg_process_queue_size > recv_flood_size; - return std::make_pair(std::move(msgs.front()), !vProcessMsg.empty()); + return std::make_pair(std::move(msgs.front()), !m_msg_process_queue.empty()); } bool CConnman::NodeFullyConnected(const CNode* pnode) diff --git a/src/net.h b/src/net.h index 9bff4416ee..7b1b7b4159 100644 --- a/src/net.h +++ b/src/net.h @@ -420,7 +420,7 @@ public: /** Move all messages from the received queue to the processing queue. */ void MarkReceivedMsgsForProcessing(unsigned int recv_flood_size) - EXCLUSIVE_LOCKS_REQUIRED(!cs_vProcessMsg); + EXCLUSIVE_LOCKS_REQUIRED(!m_msg_process_queue_mutex); /** Poll the next message from the processing queue of this connection. * @@ -428,7 +428,7 @@ public: * consisting of the message and a bool that indicates if the processing * queue has more entries. */ std::optional> PollMessage(size_t recv_flood_size) - EXCLUSIVE_LOCKS_REQUIRED(!cs_vProcessMsg); + EXCLUSIVE_LOCKS_REQUIRED(!m_msg_process_queue_mutex); bool IsOutboundOrBlockRelayConn() const { switch (m_conn_type) { @@ -615,9 +615,9 @@ private: std::list vRecvMsg; // Used only by SocketHandler thread - Mutex cs_vProcessMsg; - std::list vProcessMsg GUARDED_BY(cs_vProcessMsg); - size_t nProcessQueueSize GUARDED_BY(cs_vProcessMsg){0}; + Mutex m_msg_process_queue_mutex; + std::list m_msg_process_queue GUARDED_BY(m_msg_process_queue_mutex); + size_t m_msg_process_queue_size GUARDED_BY(m_msg_process_queue_mutex){0}; // Our address, as reported by the peer CService addrLocal GUARDED_BY(m_addr_local_mutex);