mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Merge #6474: perf: NodesSnapshot, do not hold m_nodes_mutex while shuffling
c005011e84
perf: NodesSnapshot, do not hold m_nodes_mutex while shuffling (pasta) Pull request description: ## Issue being fixed or feature implemented Upstream, as expected, only holds m_nodes_mutex while needed. We hold it a bit too long36f5effa17/src/net.h (L1628-L1640)
Not sure how this got introduced. I also don't expect this to be a major contention savior, as there is only one instance in ThreadMessageHandler where we actually do shuffle, but still, might as well fix. ## What was done? ## How Has This Been Tested? builds ## Breaking Changes None ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: kwvg: utACKc005011e84
UdjinM6: utACKc005011e84
Tree-SHA512: 76a848ace9a746c851e0fc1f66def92d67da92e9f295b7aade5a23f7d76b3eb3c28b7a6ac9d04df6dc252c1f1d9fae364821e9416a1f003a2905a30fc51eb41f
This commit is contained in:
commit
35fa4806eb
16
src/net.cpp
16
src/net.cpp
@ -5118,16 +5118,16 @@ bool CConnman::IsMasternodeOrDisconnectRequested(const CService& addr) {
|
||||
CConnman::NodesSnapshot::NodesSnapshot(const CConnman& connman, std::function<bool(const CNode* pnode)> filter,
|
||||
bool shuffle)
|
||||
{
|
||||
LOCK(connman.m_nodes_mutex);
|
||||
m_nodes_copy.reserve(connman.m_nodes.size());
|
||||
{
|
||||
LOCK(connman.m_nodes_mutex);
|
||||
m_nodes_copy.reserve(connman.m_nodes.size());
|
||||
|
||||
for (auto& node : connman.m_nodes) {
|
||||
if (!filter(node))
|
||||
continue;
|
||||
node->AddRef();
|
||||
m_nodes_copy.push_back(node);
|
||||
for (auto& node : connman.m_nodes) {
|
||||
if (!filter(node)) continue;
|
||||
node->AddRef();
|
||||
m_nodes_copy.push_back(node);
|
||||
}
|
||||
}
|
||||
|
||||
if (shuffle) {
|
||||
Shuffle(m_nodes_copy.begin(), m_nodes_copy.end(), FastRandomContext{});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user