RecursiveMutex m_tx_inventory_mutex
and also adds AssertLockNotHeld
macros combined with LOCKS_EXCLUDED
thread safety annotations to avoid recursive locking.
m_tx_inventory_mutex
with Mutex and rename it
#24125
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
See the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
3844@@ -3844,6 +3845,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3845 }
3846
3847 if (msg_type == NetMsgType::MEMPOOL) {
3848+
nit:
Approach ACK d097e5dc3356c1e2d9d4030af14ccc0ac058d6e0
cs_tx_inventory
-> m_tx_inventory_mutex
.m_tx_inventory_mutex
are protected by a preceding AssertLockNotHeld()
statement.AssertLockNotHeld()
is used.There is a minor nit that you should address before merging this PR. :clinking_glasses:
To address the external synchronizing, the code snippets below should be encapsulated as CNode::TxRelay
methods?
To address the external synchronizing, the code snippets below should be encapsulated as
CNode::TxRelay
methods?
That is my guess. Of course, it would be nice to hear other devs opinion.
The new commit addresses most of #24125 (comment).
All code snippets protected by cs_tx_inventory\m_tx_inventory_mutex
(except for the one in PeerManagerImpl::SendMessages(CNode* pto)
) were encapsulated in struct CNode::TxRelay
.
Annotations that use negative capabilities were also added.
It doesn’t seem trivial to bring the code in PeerManagerImpl::SendMessages(CNode* pto)
into net.cpp
, as it uses a significant amount of net_processing
objects and references. I will try to find a way to do this.
It doesn’t seem trivial to bring the code in PeerManagerImpl::SendMessages(CNode* pto) into net.cpp, as it uses a significant amount of net_processing objects and references. I will try to find a way to do this. @hebasto I hadn’t seen the message before. I will try to solve the issue described in the comment above.
It doesn’t seem trivial to bring the code in PeerManagerImpl::SendMessages(CNode* pto) into net.cpp, as it uses a significant amount of net_processing objects and references. I will try to find a way to do this. @hebasto 88777c4 does the trick, apparently with no change in behavior.. However, I’m not sure it’s an elegant solution due to the amount of parameters. I’m pushing it anyway so that reviewers can eventually suggest some improvement.
This commit also makes it easier to change RecursiveMutex m_bloom_filter_mutex
to Mutex
Are you still working on this?
The PR is ready for reviews.
PR title and description should be updated
Done.
332+ AssertLockNotHeld(m_tx_inventory_mutex);
333+ LOCK(m_tx_inventory_mutex);
334+ m_send_mempool = value;
335+ }
336+
337+ void Relay(
m_tx_inventory_mutex
from outside of the CNode::TxRelay
instance).
Perhaps this requires a more complex refactoring.
🐙 This pull request conflicts with the target branch and needs rebase.