mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 10:42:13 +02:00
Merge #19979: Replace LockAssertion with AssertLockHeld, remove LockAssertion
0bd1184adfRemove unused LockAssertion struct (Hennadii Stepanov)ab2a44297fReplace LockAssertion with a proper thread safety annotations (Hennadii Stepanov)73f71e1996refactor: Use explicit function type instead of template (Hennadii Stepanov) Pull request description: This PR replaces `LockAssertion` with `AssertLockHeld`, and removes `LockAssertion`. This PR is compared with alternatives in https://github.com/bitcoin-core/bitcoin-devwiki/wiki/AssertLockHeld-PRs ACKs for top commit: MarcoFalke: ACK0bd1184adfajtowns: ACK0bd1184adfvasild: ACK0bd1184adTree-SHA512: ef7780dd689faf0bb479fdb97c49bc652e2dd10c148234bb95502dfbb676442d8565ee37864d923ca21a25f9dc2a335bf46ee82c095e387b59a664ab05c0ae41
This commit is contained in:
@@ -793,25 +793,6 @@ bool ChainstateManager::ProcessNewBlock(...)
|
||||
}
|
||||
```
|
||||
|
||||
- When Clang Thread Safety Analysis is unable to determine if a mutex is locked, use `LockAssertion` class instances:
|
||||
|
||||
```C++
|
||||
// net_processing.h
|
||||
void RelayTransaction(...) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
|
||||
// net_processing.cpp
|
||||
void RelayTransaction(...)
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
|
||||
connman.ForEachNode([&txid, &wtxid](CNode* pnode) {
|
||||
LockAssertion lock(::cs_main);
|
||||
...
|
||||
});
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
- Build and run tests with `-DDEBUG_LOCKORDER` to verify that no potential
|
||||
deadlocks are introduced. As of 0.12, this is defined by default when
|
||||
configuring with `--enable-debug`.
|
||||
|
||||
Reference in New Issue
Block a user