From: cedric Date: Fri, 23 Sep 2011 13:17:12 +0000 (+0000) Subject: eina: correctly track lock when waiting for condition. X-Git-Tag: 2.0_alpha~61^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6405edfcb950760f398e1217b1729a618e7828be;p=framework%2Fuifw%2Feina.git eina: correctly track lock when waiting for condition. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@63566 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- 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