mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-12 16:45:40 +01:00
Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSection
They should also work with any other mutex type which std::unique_lock supports. There is no change in behavior for current code that calls these macros with CCriticalSection mutexes.
This commit is contained in:
@@ -7,16 +7,10 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(sync_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(potential_deadlock_detected)
|
||||
namespace {
|
||||
template <typename MutexType>
|
||||
void TestPotentialDeadLockDetected(MutexType& mutex1, MutexType& mutex2)
|
||||
{
|
||||
#ifdef DEBUG_LOCKORDER
|
||||
bool prev = g_debug_lockorder_abort;
|
||||
g_debug_lockorder_abort = false;
|
||||
#endif
|
||||
|
||||
CCriticalSection mutex1, mutex2;
|
||||
{
|
||||
LOCK2(mutex1, mutex2);
|
||||
}
|
||||
@@ -32,6 +26,23 @@ BOOST_AUTO_TEST_CASE(potential_deadlock_detected)
|
||||
#else
|
||||
BOOST_CHECK(!error_thrown);
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(sync_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(potential_deadlock_detected)
|
||||
{
|
||||
#ifdef DEBUG_LOCKORDER
|
||||
bool prev = g_debug_lockorder_abort;
|
||||
g_debug_lockorder_abort = false;
|
||||
#endif
|
||||
|
||||
CCriticalSection rmutex1, rmutex2;
|
||||
TestPotentialDeadLockDetected(rmutex1, rmutex2);
|
||||
|
||||
CWaitableCriticalSection mutex1, mutex2;
|
||||
TestPotentialDeadLockDetected(mutex1, mutex2);
|
||||
|
||||
#ifdef DEBUG_LOCKORDER
|
||||
g_debug_lockorder_abort = prev;
|
||||
|
||||
Reference in New Issue
Block a user