discomfitor pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=6b91b6a38984a0638d37eb025fc75a3796878d06
commit 6b91b6a38984a0638d37eb025fc75a3796878d06 Author: Mike Blumenkrantz <[email protected]> Date: Mon Jun 25 15:15:32 2018 -0400 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 --- src/lib/eina/eina_inline_lock_posix.x | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib/eina/eina_inline_lock_posix.x b/src/lib/eina/eina_inline_lock_posix.x index 8ae3f89566..bbcd97be86 100644 --- a/src/lib/eina/eina_inline_lock_posix.x +++ b/src/lib/eina/eina_inline_lock_posix.x @@ -250,6 +250,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) { struct timeval t0, t1; @@ -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); --
