mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 11:13:23 -03:00
Merge bitcoin/bitcoin#24079: refactor: replace RecursiveMutex cs_SubVer
with Mutex (and rename)
30927cb530
refactor: replace RecursiveMutex `m_subver_mutex` with Mutex (Sebastian Falbesoner)0639aba42a
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: ACK30927cb530
, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 2faead792ea0b2f79f9f7fe99acde5cf2bfcd2f15c51fbb6cb1099d4f81276001a492f7d46a5139055f4366c2d58a36a8ba19f21d56df20e0ed93af3141dbe11
This commit is contained in:
commit
dbf81a73e3
3 changed files with 4 additions and 4 deletions
|
@ -595,7 +595,7 @@ void CNode::CopyStats(CNodeStats& stats)
|
||||||
X(m_addr_name);
|
X(m_addr_name);
|
||||||
X(nVersion);
|
X(nVersion);
|
||||||
{
|
{
|
||||||
LOCK(cs_SubVer);
|
LOCK(m_subver_mutex);
|
||||||
X(cleanSubVer);
|
X(cleanSubVer);
|
||||||
}
|
}
|
||||||
stats.fInbound = IsInboundConn();
|
stats.fInbound = IsInboundConn();
|
||||||
|
|
|
@ -434,12 +434,12 @@ public:
|
||||||
//! Whether this peer is an inbound onion, i.e. connected via our Tor onion service.
|
//! Whether this peer is an inbound onion, i.e. connected via our Tor onion service.
|
||||||
const bool m_inbound_onion;
|
const bool m_inbound_onion;
|
||||||
std::atomic<int> nVersion{0};
|
std::atomic<int> nVersion{0};
|
||||||
RecursiveMutex cs_SubVer;
|
Mutex m_subver_mutex;
|
||||||
/**
|
/**
|
||||||
* cleanSubVer is a sanitized string of the user agent byte array we read
|
* cleanSubVer is a sanitized string of the user agent byte array we read
|
||||||
* from the wire. This cleaned string can safely be logged or displayed.
|
* from the wire. This cleaned string can safely be logged or displayed.
|
||||||
*/
|
*/
|
||||||
std::string cleanSubVer GUARDED_BY(cs_SubVer){};
|
std::string cleanSubVer GUARDED_BY(m_subver_mutex){};
|
||||||
bool m_prefer_evict{false}; // This peer is preferred for eviction.
|
bool m_prefer_evict{false}; // This peer is preferred for eviction.
|
||||||
bool HasPermission(NetPermissionFlags permission) const {
|
bool HasPermission(NetPermissionFlags permission) const {
|
||||||
return NetPermissions::HasFlag(m_permissionFlags, permission);
|
return NetPermissions::HasFlag(m_permissionFlags, permission);
|
||||||
|
|
|
@ -2636,7 +2636,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
pfrom.nServices = nServices;
|
pfrom.nServices = nServices;
|
||||||
pfrom.SetAddrLocal(addrMe);
|
pfrom.SetAddrLocal(addrMe);
|
||||||
{
|
{
|
||||||
LOCK(pfrom.cs_SubVer);
|
LOCK(pfrom.m_subver_mutex);
|
||||||
pfrom.cleanSubVer = cleanSubVer;
|
pfrom.cleanSubVer = cleanSubVer;
|
||||||
}
|
}
|
||||||
peer->m_starting_height = starting_height;
|
peer->m_starting_height = starting_height;
|
||||||
|
|
Loading…
Add table
Reference in a new issue