diff --git a/src/sync.h b/src/sync.h --- a/src/sync.h +++ b/src/sync.h @@ -56,9 +56,11 @@ std::string LocksHeld(); template void AssertLockHeldInternal(const char *pszName, const char *pszFile, int nLine, - MutexType *cs); + MutexType *cs) EXCLUSIVE_LOCKS_REQUIRED(cs); +template void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, - int nLine, void *cs); + int nLine, MutexType *cs) + EXCLUSIVE_LOCKS_REQUIRED(!cs); void DeleteLock(void *cs); bool LockStackEmpty(); @@ -77,9 +79,12 @@ int line) {} template inline void AssertLockHeldInternal(const char *pszName, const char *pszFile, - int nLine, MutexType *cs) {} -inline void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, - int nLine, void *cs) {} + int nLine, MutexType *cs) + EXCLUSIVE_LOCKS_REQUIRED(cs) {} +template +void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, + int nLine, MutexType *cs) + EXCLUSIVE_LOCKS_REQUIRED(!cs) {} inline void DeleteLock(void *cs) {} inline bool LockStackEmpty() { return true; diff --git a/src/sync.cpp b/src/sync.cpp --- a/src/sync.cpp +++ b/src/sync.cpp @@ -243,8 +243,9 @@ template void AssertLockHeldInternal(const char *, const char *, int, RecursiveMutex *); +template void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, - int nLine, void *cs) { + int nLine, MutexType *cs) { if (!LockHeld(cs)) { return; } @@ -253,6 +254,10 @@ pszName, pszFile, nLine, LocksHeld()); abort(); } +template void AssertLockNotHeldInternal(const char *, const char *, int, + Mutex *); +template void AssertLockNotHeldInternal(const char *, const char *, int, + RecursiveMutex *); void DeleteLock(void *cs) { LockData &lockdata = GetLockData(); diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -448,7 +448,7 @@ bool CheckSequenceLocks(const CTxMemPool &pool, const CTransaction &tx, int flags, LockPoints *lp = nullptr, bool useExistingLockPoints = false) - EXCLUSIVE_LOCKS_REQUIRED(cs_main); + EXCLUSIVE_LOCKS_REQUIRED(::cs_main, pool.cs); /** * Closure representing one script verification. diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1426,7 +1426,7 @@ * deadlock */ void BlockUntilSyncedToCurrentChain() const - LOCKS_EXCLUDED(cs_main, cs_wallet); + EXCLUSIVE_LOCKS_REQUIRED(!::cs_main, !cs_wallet); /** * Set a single wallet flag.