1
0
Fork 0
forked from lthn/blockchain

extra logging on VALIDATE_MUTEX_IS_FREE

This commit is contained in:
cryptozoidberg 2020-07-03 13:09:44 +02:00
parent 5f80d02458
commit 93407a038e
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC

View file

@ -41,18 +41,6 @@
//#define DISABLE_DEADLOCK_GUARD
#define VALIDATE_MUTEX_IS_FREE(mutex_mame) \
if (mutex_mame.try_lock()) \
{ \
mutex_mame.unlock(); \
return; \
} \
else \
{ \
LOG_ERROR("MUTEX IS NOT FREE ON DESTRUCTOR: " << #mutex_mame); \
}
namespace epee
{
@ -640,13 +628,27 @@ namespace epee
#define DEADLOCK_LOCATION __FILE__ ":" DEADLOCK_STRINGIFY(__LINE__)
/*
/*
We do DEADLOCK_LOCATION and DEADLOCK_FUNCTION_DEF as separate variables passed into deadlock_guard
because in GCC __PRETTY_FUNCTION__ is not a literal (like __FILE__ macro) but const variable, and
can't concatenate it with other macro like we did in DEADLOCK_LOCATION.
*/
#define VALIDATE_MUTEX_IS_FREE(mutex_mame) \
if (mutex_mame.try_lock()) \
{ \
mutex_mame.unlock(); \
return; \
} \
else \
{ \
auto state_str = epee::deadlock_guard_singleton::get_dlg_state(); \
LOG_ERROR("MUTEX IS NOT FREE ON DESTRUCTOR: " << #mutex_mame << ", address:" << (void*)&mutex_mame << ENDL << "DEAD LOCK GUARD state:" << ENDL << state_str); \
}
We do DEADLOCK_LOCATION and DEADLOCK_FUNCTION_DEF as separate variables passed into deadlock_guard
because in GCC __PRETTY_FUNCTION__ is not a literal (like __FILE__ macro) but const variable, and
can't concatenate it with other macro like we did in DEADLOCK_LOCATION.
*/
#define DLG_CRITICAL_REGION_LOCAL_VAR(lock, varname) epee::guarded_critical_region_t<decltype(lock)> varname(lock, DEADLOCK_FUNCTION_DEF, DEADLOCK_LOCATION, #lock, epee::log_space::log_singletone::get_thread_log_prefix())
#define DLG_CRITICAL_REGION_BEGIN_VAR(lock, varname) { epee::guarded_critical_region_t<decltype(lock)> varname(lock, DEADLOCK_FUNCTION_DEF, DEADLOCK_LOCATION, #lock, epee::log_space::log_singletone::get_thread_log_prefix())