Page MenuHomePhabricator

refactor: replace RecursiveMutex m_most_recent_block_mutex with Mutex
ClosedPublic

Authored by PiRK on Nov 30 2023, 10:22.

Details

Summary

refactor: reduce scope of lock m_most_recent_block_mutex

This avoids calling the non-trivial method
CConnman::PushMessage within the critical section.

refactor: replace RecursiveMutex m_most_recent_block_mutex with Mutex

In each of the critical sections, only the the guarded variables are
accessed, without any chance that within one section another one is
called. Hence, we can use an ordinary Mutex instead of RecursiveMutex.

This is a backport of core#24062

Depends on D14878

Test Plan
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug  -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
ninja all check-all

Event Timeline

PiRK requested review of this revision.Nov 30 2023, 10:22
Fabien added inline comments.
src/net_processing.cpp
6994

This change is unrelated to the mutex being non recursive right ? AFAICT there is no lock removal in this change

src/net_processing.cpp
6994

The goal is to reduce the scope of the lock by moving PushMessage out of the scope of the lock, but I don't think it was strictly necessary, I don't see how PushMessage could take that lock.
The rationale is just that PushMessage is "non-trivial"

This revision is now accepted and ready to land.Dec 1 2023, 09:08