-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Replace RecursiveMutex cs_mapLocalHost
with Mutex, and rename it
#24099
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. 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. |
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.
Approach ACK 3e05ab9.
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.
Approach ACK 3e05ab9
Going commit wise:
- The renaming of the mutex
cs_mapLocalHost
->map_localhost_mutex
, is an improvement, in my opinion. - The type of
map_localhost_mutex
is changed from RecursiveMutex to Mutex. I checked through the codebase wheremap_localhost_mutex
is used for any instances of recursive lockings, and I found none. Also, I was able to compile this PR without any UB warnings successfully. So I think it’s safe to convert the type of this mutex from RecursiveMutex to Mutex.
I shall ACK this PR as soon as this suggestion by @hebasto is addressed.
-BEGIN VERIFY SCRIPT- s() { sed -i 's/cs_mapLocalHost/g_maplocalhost_mutex/g' $1; } s src/net.cpp s src/net.h s src/rpc/net.cpp s src/test/net_tests.cpp -END VERIFY SCRIPT-
3e05ab9
to
5e7e4c9
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 5e7e4c9
Changes since my last review:
map_localhost_mutex
->g_maplocalhost_mutex
.
The updated PR compiled successfully on Ubuntu 20.04.
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 5e7e4c9
Checked that within all critical sections that are protected by g_maplocalhost_mutex
, there is no chance another one is called, i.e. a regular Mutex is sufficient.
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 5e7e4c9, I have reviewed the code and it looks OK, I agree it can be merged.
In particular, I've verified that there are no recursive mutex locking on the path GetLocal()
--> CNetAddr::GetReachabilityFrom()
--> CNetAddr::IsRoutable()
.
A script in the "scripted-diff" commit could be more robust:
sed -i 's/cs_mapLocalHost/g_maplocalhost_mutex/g' -- $(git grep --files-with-matches 'cs_mapLocalHost')
This PR is related to #19303 and gets rid of the
RecursiveMutex cs_mapLocalHost
.