aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-06-25 15:15:32 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-06-25 15:15:32 -0400
commit6b91b6a38984a0638d37eb025fc75a3796878d06 (patch)
tree95db93cb479a616aa61d5e9d8a2b69ea9daf6790
parenteina/lock: reorder inline posix lock functions (diff)
downloadefl-6b91b6a38984a0638d37eb025fc75a3796878d06.tar.gz
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 https://phab.enlightenment.org/D6374 Reviewers: ManMower, devilhorns Reviewed By: devilhorns Subscribers: cedric, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D6375
-rw-r--r--src/lib/eina/eina_inline_lock_posix.x8
1 files changed, 8 insertions, 0 deletions
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);