Fixed infinite recursion bug in PTHREAD_MUTEX_INITIALIZER.

This commit is contained in:
Joel Sherrill
1997-08-22 19:11:02 +00:00
parent 799a5b9f8d
commit 9b1f5678c2
2 changed files with 30 additions and 20 deletions

View File

@@ -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;

View File

@@ -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;