eina/lock: when debug threads are enabled, always call trylock in lock function

Summary:
when debugging thread issues, it's not actually helpful to immediately
deadlock--this defeats any attempt at debugging. instead, call trylock first
in order to detect a possible deadlock and then throw an error which can be
caught by the user
Depends on D6374

Reviewers: ManMower, devilhorns

Reviewed By: devilhorns

Subscribers: cedric, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6375
This commit is contained in:
Mike Blumenkrantz 2018-06-25 15:15:32 -04:00
parent 73ba4006bd
commit 6b91b6a389
1 changed files with 8 additions and 0 deletions

View File

@ -249,6 +249,10 @@ eina_lock_take(Eina_Lock *mutex)
}
#endif
#ifdef EINA_HAVE_DEBUG_THREADS
if (eina_lock_take_try(mutex) == EINA_LOCK_SUCCEED) return EINA_LOCK_SUCCEED;
#endif
#ifdef EINA_HAVE_DEBUG_THREADS
if (_eina_threads_debug)
{
@ -654,6 +658,10 @@ eina_spinlock_take(Eina_Spinlock *spinlock)
#if defined(EINA_HAVE_POSIX_SPINLOCK)
int t;
#ifdef EINA_HAVE_DEBUG_THREADS
if (eina_spinlock_take_try(spinlock) == EINA_LOCK_SUCCEED) return EINA_LOCK_SUCCEED;
#endif
for (;;)
{
t = pthread_spin_lock(spinlock);