Skip to content

Commit

Permalink
merge bitcoin#24079: replace RecursiveMutex cs_SubVer with Mutex (and…
Browse files Browse the repository at this point in the history
… rename)
  • Loading branch information
kwvg committed May 9, 2024
1 parent 23b152c commit 2f7a138
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
X(m_addr_name);
X(nVersion);
{
LOCK(cs_SubVer);
LOCK(m_subver_mutex);
X(cleanSubVer);
}
stats.fInbound = IsInboundConn();
Expand Down
4 changes: 2 additions & 2 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,12 @@ class CNode
const bool m_inbound_onion;
std::atomic<int> nNumWarningsSkipped{0};
std::atomic<int> nVersion{0};
Mutex m_subver_mutex;
/**
* 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.
*/
std::string cleanSubVer GUARDED_BY(cs_SubVer){};
RecursiveMutex cs_SubVer; // used for both cleanSubVer and strSubVer
std::string cleanSubVer GUARDED_BY(m_subver_mutex){};
bool m_prefer_evict{false}; // This peer is preferred for eviction.
bool HasPermission(NetPermissionFlags permission) const {
return NetPermissions::HasFlag(m_permissionFlags, permission);
Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3357,7 +3357,7 @@ void PeerManagerImpl::ProcessMessage(
pfrom.nServices = nServices;
pfrom.SetAddrLocal(addrMe);
{
LOCK(pfrom.cs_SubVer);
LOCK(pfrom.m_subver_mutex);
pfrom.cleanSubVer = cleanSubVer;
}
peer->m_starting_height = starting_height;
Expand Down

0 comments on commit 2f7a138

Please sign in to comment.