forked from Imagelibrary/rtems
Fixed infinite recursion bug in PTHREAD_MUTEX_INITIALIZER.
This commit is contained in:
@@ -230,17 +230,22 @@ int pthread_mutex_init(
|
|||||||
if ( !mutex )
|
if ( !mutex )
|
||||||
return EINVAL;
|
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 );
|
if ( *mutex != PTHREAD_MUTEX_INITIALIZER ) {
|
||||||
switch ( location ) {
|
|
||||||
case OBJECTS_ERROR:
|
/* EBUSY if *mutex is a valid id */
|
||||||
break;
|
|
||||||
case OBJECTS_REMOTE:
|
mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
|
||||||
case OBJECTS_LOCAL:
|
switch ( location ) {
|
||||||
_Thread_Enable_dispatch();
|
case OBJECTS_ERROR:
|
||||||
return EBUSY;
|
break;
|
||||||
};
|
case OBJECTS_REMOTE:
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
_Thread_Enable_dispatch();
|
||||||
|
return EBUSY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !the_attr->is_initialized )
|
if ( !the_attr->is_initialized )
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|||||||
@@ -230,17 +230,22 @@ int pthread_mutex_init(
|
|||||||
if ( !mutex )
|
if ( !mutex )
|
||||||
return EINVAL;
|
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 );
|
if ( *mutex != PTHREAD_MUTEX_INITIALIZER ) {
|
||||||
switch ( location ) {
|
|
||||||
case OBJECTS_ERROR:
|
/* EBUSY if *mutex is a valid id */
|
||||||
break;
|
|
||||||
case OBJECTS_REMOTE:
|
mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
|
||||||
case OBJECTS_LOCAL:
|
switch ( location ) {
|
||||||
_Thread_Enable_dispatch();
|
case OBJECTS_ERROR:
|
||||||
return EBUSY;
|
break;
|
||||||
};
|
case OBJECTS_REMOTE:
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
_Thread_Enable_dispatch();
|
||||||
|
return EBUSY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !the_attr->is_initialized )
|
if ( !the_attr->is_initialized )
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|||||||
Reference in New Issue
Block a user