posix: fix error return code for pthread_mutex_trylock

pthread_mutex_trylock() should return EBUSY if the mutex is already
locked. The translations of CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED is
EDEADLK which is correct for pthread_mutex_lock(). This fixes the
translation for trylock.

Closes #2170.
This commit is contained in:
Gedare Bloom
2015-02-24 10:27:08 -05:00
parent ee87007748
commit c0e01a28da
2 changed files with 6 additions and 3 deletions

View File

@@ -37,5 +37,8 @@ int pthread_mutex_trylock(
pthread_mutex_t *mutex pthread_mutex_t *mutex
) )
{ {
return _POSIX_Mutex_Lock_support( mutex, false, THREAD_QUEUE_WAIT_FOREVER ); int r = _POSIX_Mutex_Lock_support( mutex, false, THREAD_QUEUE_WAIT_FOREVER );
if ( r == EDEADLK )
r = EBUSY;
return r;
} }

View File

@@ -580,8 +580,8 @@ The mutex has the protocol attribute of PTHREAD_PRIO_PROTECT and the
priority of the calling thread is higher than the current priority priority of the calling thread is higher than the current priority
ceiling. ceiling.
@item EDEADLK @item EBUSY
The current thread already owns the mutex. The mutex is already locked.
@end table @end table