From: raster Date: Mon, 2 May 2011 08:34:22 +0000 (+0000) Subject: also return deadlock from normal lock (not try only) X-Git-Tag: submit/2.0alpha-wayland/20121127.222009~698 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dad666eab03bfa43d1336984177fb33a6d81b901;p=profile%2Fivi%2Feina.git also return deadlock from normal lock (not try only) git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eina@59103 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/include/eina_inline_lock_posix.x b/src/include/eina_inline_lock_posix.x index 5de513f..89c1d02 100644 --- a/src/include/eina_inline_lock_posix.x +++ b/src/include/eina_inline_lock_posix.x @@ -110,7 +110,9 @@ eina_lock_free(Eina_Lock *mutex) static inline Eina_Lock_Result eina_lock_take(Eina_Lock *mutex) { - Eina_Bool ret; + Eina_Bool ret = EINA_FALSE; + int ok; + #ifdef EINA_HAVE_DEBUG_THREADS if (_eina_threads_debug) { @@ -131,8 +133,13 @@ eina_lock_take(Eina_Lock *mutex) if (dt > _eina_threads_debug) abort(); } #endif - ret = (pthread_mutex_lock(&(mutex->mutex)) == 0) ? - EINA_TRUE : EINA_FALSE; + ok = pthread_mutex_lock(&(mutex->mutex)); + if (ok == 0) ret = EINA_TRUE; + else if (ok == EDEADLK) + { + printf("ERROR ERROR: DEADLOCK on lock %p\n", mutex); + ret = EINA_LOCK_DEADLOCK; // magic + } #ifdef EINA_LOCK_DEBUG mutex->locked = 1; mutex->lock_thread_id = pthread_self(); @@ -151,7 +158,7 @@ eina_lock_take_try(Eina_Lock *mutex) if (ok == 0) ret = EINA_TRUE; else if (ok == EDEADLK) { - printf("ERROR ERROR: DEADLOCK on lock %p\n", mutex); + printf("ERROR ERROR: DEADLOCK on trylock %p\n", mutex); ret = EINA_LOCK_DEADLOCK; // magic } #ifdef EINA_LOCK_DEBUG