HomePhabricator

Avoid locking mutexes that are already held by the same thread

Description

Avoid locking mutexes that are already held by the same thread

Summary:
Avoid locking mutexes that are already held by the same thread. These are reentrant mutexes, but still no need to lock them more than once per thread :-)

Backport of Bitcoin Core PR11762
https://github.com/bitcoin/bitcoin/pull/11762

Test Plan:

  1. Build with Clang in Debug mode:
CXX=clang++ CC=clang cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug
ninja check
  1. Verify that the compiler has not emitted a thread-safety warning.
  2. Run the node: ./src/bitcoind -regtest
  3. Verify that text similar to "Assertion failed: lock ... not held ..." is not printed on stderr.

Reviewers: Fabien, #bitcoin_abc, deadalnix

Reviewed By: Fabien, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D4145

Details

Provenance
practicalswift <practicalswift@users.noreply.github.com>Authored on Sep 27 2019, 13:42
fpelliccioniCommitted on Sep 27 2019, 14:24
fpelliccioniPushed on Sep 27 2019, 14:24
Reviewer
Restricted Project
Differential Revision
D4145: Avoid locking mutexes that are already held by the same thread
Parents
rABC9d80a5e3f9b7: Added net debug info to IBD builds
Branches
Unknown
Tags
Unknown