Skip to content

Commit dbf81a7

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#24079: refactor: replace RecursiveMutex cs_SubVer with Mutex (and rename)
30927cb refactor: replace RecursiveMutex `m_subver_mutex` with Mutex (Sebastian Falbesoner) 0639aba scripted-diff: rename `cs_SubVer` -> `m_subver_mutex` (Sebastian Falbesoner) Pull request description: This PR is related to #19303 and gets rid of the RecursiveMutex `cs_SubVer`. Both of the critical sections only directly access the guarded variable, i.e. it is not possible that within one section another one is called, and we can use a regular Mutex. ACKs for top commit: hebasto: ACK 30927cb, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 2faead792ea0b2f79f9f7fe99acde5cf2bfcd2f15c51fbb6cb1099d4f81276001a492f7d46a5139055f4366c2d58a36a8ba19f21d56df20e0ed93af3141dbe11
2 parents 92a71f6 + 30927cb commit dbf81a7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ void CNode::CopyStats(CNodeStats& stats)
595595
X(m_addr_name);
596596
X(nVersion);
597597
{
598-
LOCK(cs_SubVer);
598+
LOCK(m_subver_mutex);
599599
X(cleanSubVer);
600600
}
601601
stats.fInbound = IsInboundConn();

src/net.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,12 @@ class CNode
434434
//! Whether this peer is an inbound onion, i.e. connected via our Tor onion service.
435435
const bool m_inbound_onion;
436436
std::atomic<int> nVersion{0};
437-
RecursiveMutex cs_SubVer;
437+
Mutex m_subver_mutex;
438438
/**
439439
* cleanSubVer is a sanitized string of the user agent byte array we read
440440
* from the wire. This cleaned string can safely be logged or displayed.
441441
*/
442-
std::string cleanSubVer GUARDED_BY(cs_SubVer){};
442+
std::string cleanSubVer GUARDED_BY(m_subver_mutex){};
443443
bool m_prefer_evict{false}; // This peer is preferred for eviction.
444444
bool HasPermission(NetPermissionFlags permission) const {
445445
return NetPermissions::HasFlag(m_permissionFlags, permission);

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
26362636
pfrom.nServices = nServices;
26372637
pfrom.SetAddrLocal(addrMe);
26382638
{
2639-
LOCK(pfrom.cs_SubVer);
2639+
LOCK(pfrom.m_subver_mutex);
26402640
pfrom.cleanSubVer = cleanSubVer;
26412641
}
26422642
peer->m_starting_height = starting_height;

0 commit comments

Comments
 (0)