summaryrefslogtreecommitdiff
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
parent73ba4006bd6e2a7cf66b6cfd24b972095dd514eb (diff)
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
-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)
250#endif 250#endif
251 251
252#ifdef EINA_HAVE_DEBUG_THREADS 252#ifdef EINA_HAVE_DEBUG_THREADS
253 if (eina_lock_take_try(mutex) == EINA_LOCK_SUCCEED) return EINA_LOCK_SUCCEED;
254#endif
255
256#ifdef EINA_HAVE_DEBUG_THREADS
253 if (_eina_threads_debug) 257 if (_eina_threads_debug)
254 { 258 {
255 struct timeval t0, t1; 259 struct timeval t0, t1;
@@ -654,6 +658,10 @@ eina_spinlock_take(Eina_Spinlock *spinlock)
654#if defined(EINA_HAVE_POSIX_SPINLOCK) 658#if defined(EINA_HAVE_POSIX_SPINLOCK)
655 int t; 659 int t;
656 660
661#ifdef EINA_HAVE_DEBUG_THREADS
662 if (eina_spinlock_take_try(spinlock) == EINA_LOCK_SUCCEED) return EINA_LOCK_SUCCEED;
663#endif
664
657 for (;;) 665 for (;;)
658 { 666 {
659 t = pthread_spin_lock(spinlock); 667 t = pthread_spin_lock(spinlock);