From 02b76b9c6eb055941cde37d9d00287426217073a Mon Sep 17 00:00:00 2001 From: cedric Date: Fri, 23 Sep 2011 13:17:12 +0000 Subject: [PATCH] eina: correctly track lock when waiting for condition. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eina@63566 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/include/eina_inline_lock_posix.x | 41 +++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/include/eina_inline_lock_posix.x b/src/include/eina_inline_lock_posix.x index f9a5666..2da5bfc 100644 --- a/src/include/eina_inline_lock_posix.x +++ b/src/include/eina_inline_lock_posix.x @@ -320,32 +320,63 @@ eina_condition_free(Eina_Condition *cond) static inline Eina_Bool eina_condition_wait(Eina_Condition *cond) { + Eina_Bool r; + #ifdef EINA_HAVE_DEBUG_THREADS assert(_eina_threads_activated); assert(cond->lock != NULL); + + pthread_mutex_lock(&_eina_tracking_lock); + _eina_tracking = eina_inlist_remove(_eina_tracking, + EINA_INLIST_GET(cond->lock)); + pthread_mutex_unlock(&_eina_tracking_lock); +#endif + + r = pthread_cond_wait(&(cond->condition), + &(cond->lock->mutex)) == 0 ? EINA_TRUE : EINA_FALSE; + +#ifdef EINA_HAVE_DEBUG_THREADS + pthread_mutex_lock(&_eina_tracking_lock); + _eina_tracking = eina_inlist_append(_eina_tracking, + EINA_INLIST_GET(cond->lock)); + pthread_mutex_unlock(&_eina_tracking_lock); #endif - return pthread_cond_wait(&(cond->condition), - &(cond->lock->mutex)) == 0 ? EINA_TRUE : EINA_FALSE; + return r; } static inline Eina_Bool eina_condition_timedwait(Eina_Condition *cond, double t) { struct timespec tv; + Eina_Bool r; #ifdef EINA_HAVE_DEBUG_THREADS assert(_eina_threads_activated); assert(cond->lock != NULL); + + pthread_mutex_lock(&_eina_tracking_lock); + _eina_tracking = eina_inlist_remove(_eina_tracking, + EINA_INLIST_GET(cond->lock)); + pthread_mutex_unlock(&_eina_tracking_lock); #endif tv.tv_sec = t; tv.tv_nsec = (t - (double) tv.tv_sec) * 1000000000; - return pthread_cond_timedwait(&(cond->condition), - &(cond->lock->mutex), - &tv) == 0 ? + r = pthread_cond_timedwait(&(cond->condition), + &(cond->lock->mutex), + &tv) == 0 ? EINA_TRUE : EINA_FALSE; + +#ifdef EINA_HAVE_DEBUG_THREADS + pthread_mutex_lock(&_eina_tracking_lock); + _eina_tracking = eina_inlist_append(_eina_tracking, + EINA_INLIST_GET(cond->lock)); + pthread_mutex_unlock(&_eina_tracking_lock); +#endif + + return r; } static inline Eina_Bool -- 2.7.4