mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 02:33:07 +02:00
Merge bitcoin/bitcoin#22829: refactor: various RecursiveMutex replacements in CConnman
3726a45958refactor: replace RecursiveMutex m_added_nodes_mutex with Mutex (Sebastian Falbesoner)7d52ff5c38refactor: replace RecursiveMutex m_addr_fetches_mutex with Mutex (Sebastian Falbesoner)d51d2a3bb5scripted-diff: rename node vector/mutex members in CConnman (Sebastian Falbesoner)574cc4271arefactor: remove RecursiveMutex cs_totalBytesRecv, use std::atomic instead (Sebastian Falbesoner) Pull request description: This PR is related to #19303 and gets rid of the following RecursiveMutex members in class `CConnman`: * for `cs_totalBytesRecv`, protecting `nTotalBytesRecv`, `std::atomic` is used instead (the member is only increment at one and read at another place, so this is sufficient) * for `m_addr_fetches_mutex`, protecting `m_addr_fetches`, a regular `Mutex` is used instead (there is no chance that within one critical section, another one is called) * for `cs_vAddedNodes`, protecting `vAddedNodes`, a regular `Mutex` is used instead (there is no chance that within one critical section, another one is called) Additionally, the PR takes the chance to rename all node vector members (vNodes, vAddedNodes) and its corresponding mutexes (cs_vNodes, cs_vAddedNodes) to match the coding guidelines via a scripted-diff. ACKs for top commit: vasild: ACK3726a45958promag: Code review ACK3726a45958. hebasto: re-ACK3726a45958Tree-SHA512: 4f5ad41ba2eca397795080988c1739c6abb44c1204dddaa75cc38a396fa821fbe1010694ba7bead1b606beaa677661e66da2a5dca233b2937214f63a54848348
This commit is contained in:
@@ -25,16 +25,16 @@ struct ConnmanTestMsg : public CConnman {
|
||||
|
||||
void AddTestNode(CNode& node)
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
vNodes.push_back(&node);
|
||||
LOCK(m_nodes_mutex);
|
||||
m_nodes.push_back(&node);
|
||||
}
|
||||
void ClearTestNodes()
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
for (CNode* node : vNodes) {
|
||||
LOCK(m_nodes_mutex);
|
||||
for (CNode* node : m_nodes) {
|
||||
delete node;
|
||||
}
|
||||
vNodes.clear();
|
||||
m_nodes.clear();
|
||||
}
|
||||
|
||||
void ProcessMessagesOnce(CNode& node) { m_msgproc->ProcessMessages(&node, flagInterruptMsgProc); }
|
||||
|
||||
Reference in New Issue
Block a user