-
Notifications
You must be signed in to change notification settings - Fork 38.7k
m_tx_download_mutex followups #30507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee 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. ConflictsReviewers, 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. |
|
Concept ACK. |
dergoegge
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 1a0212c8e5c25fce2e0a2cab3113b25f2fbc38b7
src/net_processing.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to myself: See if ACQUIRED_BEFORE helps here at compile time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, added a ACQUIRED_BEFORE, but compiler didn't complain when I added a LOCK2(m_mempool.cs, m_tx_download_mutex)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From https://clang.llvm.org/docs/ThreadSafetyAnalysis.html:
ACQUIRED_BEFORE(…)andACQUIRED_AFTER(…)are currently being developed under the-Wthread-safety-betaflag.
Hm, added a
ACQUIRED_BEFORE, but compiler didn't complain when I added aLOCK2(m_mempool.cs, m_tx_download_mutex)
With CXXFLAGS=-Wthread-safety-beta, clang emits a warning:
net_processing.cpp:2078:5: warning: mutex 'm_tx_download_mutex' must be acquired before 'cs' [-Wthread-safety-analysis]
LOCK2(m_mempool.cs, m_tx_download_mutex);
^
./sync.h:260:16: note: expanded from macro 'LOCK2'
UniqueLock criticalblock2(MaybeCheckNotHeld(cs2), #cs2, __FILE__, __LINE__)
^
1 warning generated.
Now that m_txrequest and m_recent_confirmed_transactions are guarded by the same mutex, there is no benefit to processing them separately. Instead, just loop through pblock->vtx once.
1a0212c to
1b732db
Compare
instagibbs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 1b732db
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm ACK 1b732dbc3bd9c59303a774cf2095c2d6639dbe1d
(happy to re-ACK if the Assert suggestion for pindexNewTip is taken)
- add AssertLockNotHeld(m_tx_download_mutex) in net_processing - move doc about m_tx_download_mutex and mempool mutex to ActiveTipChange
1b732db to
7c29e55
Compare
|
reACK 7c29e55 |
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK 7c29e55
dergoegge
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK 7c29e55
hebasto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post-merge ACK 7c29e55.
Followup to #30111. Includes suggestions: