[rtems commit] posix: fix error return code for pthread_mutex_trylock

Gedare Bloom gedare at rtems.org
Wed Feb 25 20:01:00 UTC 2015


Module:    rtems
Branch:    master
Commit:    c0e01a28dad77063d8edb7f7fe2cee83a5f09b2e
Changeset: http://git.rtems.org/rtems/commit/?id=c0e01a28dad77063d8edb7f7fe2cee83a5f09b2e

Author:    Gedare Bloom <gedare at rtems.org>
Date:      Tue Feb 24 10:27:08 2015 -0500

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.

---

 cpukit/posix/src/mutextrylock.c | 5 ++++-
 doc/posix_users/mutex.t         | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/cpukit/posix/src/mutextrylock.c b/cpukit/posix/src/mutextrylock.c
index b6e79cd..332f486 100644
--- a/cpukit/posix/src/mutextrylock.c
+++ b/cpukit/posix/src/mutextrylock.c
@@ -37,5 +37,8 @@ int pthread_mutex_trylock(
   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;
 }
diff --git a/doc/posix_users/mutex.t b/doc/posix_users/mutex.t
index b894538..47f094d 100644
--- a/doc/posix_users/mutex.t
+++ b/doc/posix_users/mutex.t
@@ -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
 ceiling.
 
- at item EDEADLK
-The current thread already owns the mutex.
+ at item EBUSY
+The mutex is already locked.
 
 @end table
 




More information about the vc mailing list