-
Notifications
You must be signed in to change notification settings - Fork 36.8k
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
Replace RecursiveMutex cs_addrLocal
with Mutex, and rename it
#24108
Conversation
-BEGIN VERIFY SCRIPT- sed -i 's/cs_addrLocal/m_addr_local_mutex/g' -- $(git grep --files-with-matches 'cs_addrLocal') -END VERIFY SCRIPT-
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 63ca568
- The new name of cs_addrLocal -> m_addr_local_mutex is an improvement.
- I checked that
m_addr_local_mutex
is being used at two places in the codebase. These instances have been addressed by Asserting Lock not held before locking the mutex. So I think it's safe to convertm_addr_local_mutex
from RecursiveMutex to 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.
Concept ACK.
Adding AssertLockNotHeld(m_addr_local_mutex)
macros should be combined with adding thread safety annotations LOCKS_EXCLUDED(m_addr_local_mutex)
in the src/net.h
. See https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#threads-and-synchronization
Also, for the safe commit history, "refactor: replace RecursiveMutex m_addr_local_mutex with Mutex" commit should follow "p2p: add assertions for m_addr_local_mutex" one.
63ca568
to
dec787d
Compare
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 dec787d, I have reviewed the code and it looks OK, I agree it can be merged.
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 dec787d
Changes since my last review:
- Added Thread Safety annotation,
LOCKS_EXCLUDED(m_addr_local_mutex)
, to theGet/Set AddrLocal()
functions' declaration. - Rearranged commits so that
m_addr_local_mutex
is converted to Mutex, after, other conditions are made right for it.
…, and rename it dec787d refactor: replace RecursiveMutex `m_addr_local_mutex` with Mutex (w0xlt) 93609c1 p2p: add assertions and negative TS annotations for m_addr_local_mutex (w0xlt) c4a31ca scripted-diff: rename cs_addrLocal -> m_addr_local_mutex (w0xlt) Pull request description: This PR is related to bitcoin#19303 and gets rid of the `RecursiveMutex cs_addrLocal`. ACKs for top commit: hebasto: ACK dec787d, I have reviewed the code and it looks OK, I agree it can be merged. shaavan: reACK dec787d Tree-SHA512: b7a043bfd4e2ccbe313bff21ad815169db6ad215ca96daf358ce960c496a548b4a9e90be9e4357430ca59652b96df87c097450118996c6d4703cbaabde2072d0
This PR is related to #19303 and gets rid of the
RecursiveMutex cs_addrLocal
.