summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/mutex.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1997-08-22 19:11:02 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1997-08-22 19:11:02 +0000
commit9b1f5678c29cc48bc5035f5bb581e506c4cf66fa (patch)
tree6cdb78b4ce98f0343c4fee6244213852a8215ebb /cpukit/posix/src/mutex.c
parentAdded commit about missing support for condition initializer. (diff)
downloadrtems-9b1f5678c29cc48bc5035f5bb581e506c4cf66fa.tar.bz2
Fixed infinite recursion bug in PTHREAD_MUTEX_INITIALIZER.
Diffstat (limited to 'cpukit/posix/src/mutex.c')
-rw-r--r--cpukit/posix/src/mutex.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/cpukit/posix/src/mutex.c b/cpukit/posix/src/mutex.c
index 037791a252..fa2ccc9cc5 100644
--- a/cpukit/posix/src/mutex.c
+++ b/cpukit/posix/src/mutex.c
@@ -230,17 +230,22 @@ int pthread_mutex_init(
if ( !mutex )
return EINVAL;
- /* EBUSY if *mutex is a valid id */
+ /* avoid infinite recursion on call to this routine in _POSIX_Mutex_Get */
- mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
- switch ( location ) {
- case OBJECTS_ERROR:
- break;
- case OBJECTS_REMOTE:
- case OBJECTS_LOCAL:
- _Thread_Enable_dispatch();
- return EBUSY;
- };
+ if ( *mutex != PTHREAD_MUTEX_INITIALIZER ) {
+
+ /* EBUSY if *mutex is a valid id */
+
+ mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
+ switch ( location ) {
+ case OBJECTS_ERROR:
+ break;
+ case OBJECTS_REMOTE:
+ case OBJECTS_LOCAL:
+ _Thread_Enable_dispatch();
+ return EBUSY;
+ }
+ }
if ( !the_attr->is_initialized )
return EINVAL;