diff options
Diffstat (limited to 'cpukit/posix/src/mutexdestroy.c')
-rw-r--r-- | cpukit/posix/src/mutexdestroy.c | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/cpukit/posix/src/mutexdestroy.c b/cpukit/posix/src/mutexdestroy.c index 57e63937a9..193f3391bc 100644 --- a/cpukit/posix/src/mutexdestroy.c +++ b/cpukit/posix/src/mutexdestroy.c @@ -29,37 +29,22 @@ int pthread_mutex_destroy( ) { POSIX_Mutex_Control *the_mutex; + unsigned long flags; Thread_queue_Context queue_context; int eno; - _Objects_Allocator_lock(); + the_mutex = _POSIX_Mutex_Get( mutex ); + POSIX_MUTEX_VALIDATE_OBJECT( the_mutex, flags ); - the_mutex = _POSIX_Mutex_Get( mutex, &queue_context ); + _POSIX_Mutex_Acquire( the_mutex, &queue_context ); - if ( the_mutex != NULL ) { - _POSIX_Mutex_Acquire_critical( the_mutex, &queue_context ); - - /* - * XXX: There is an error for the mutex being locked - * or being in use by a condition variable. - */ - - if ( - !_CORE_mutex_Is_locked( &the_mutex->Mutex.Recursive.Mutex ) - ) { - _Objects_Close( &_POSIX_Mutex_Information, &the_mutex->Object ); - _POSIX_Mutex_Release( the_mutex, &queue_context ); - _CORE_mutex_Destroy( &the_mutex->Mutex.Recursive.Mutex ); - _POSIX_Mutex_Free( the_mutex ); - eno = 0; - } else { - _POSIX_Mutex_Release( the_mutex, &queue_context ); - eno = EBUSY; - } + if ( _POSIX_Mutex_Get_owner( the_mutex ) == NULL ) { + the_mutex->flags = ~the_mutex->flags; + eno = 0; } else { - eno = EINVAL; + eno = EBUSY; } - _Objects_Allocator_unlock(); + _POSIX_Mutex_Release( the_mutex, &queue_context ); return eno; } |