2007-05-22 Joel Sherrill <joel.sherrill@OARcorp.com>

* score/src/corerwlockrelease.c: Do not dereference NULL.
This commit is contained in:
Joel Sherrill
2007-05-22 15:02:02 +00:00
parent 7860a37e64
commit e5200d5afe
2 changed files with 26 additions and 21 deletions

View File

@@ -1,3 +1,7 @@
2007-05-22 Joel Sherrill <joel.sherrill@OARcorp.com>
* score/src/corerwlockrelease.c: Do not dereference NULL.
2007-05-21 Joel Sherrill <joel.sherrill@oarcorp.com>
* rtems/Makefile.am, rtems/include/rtems/rtems/barrier.h,

View File

@@ -79,32 +79,33 @@ CORE_RWLock_Status _CORE_RWLock_Release(
next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue );
rwmode = next->Wait.option;
if ( rwmode == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) {
the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING;
return CORE_RWLOCK_SUCCESSFUL;
}
if ( next ) {
rwmode = next->Wait.option;
if ( rwmode == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) {
the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING;
return CORE_RWLOCK_SUCCESSFUL;
}
/*
* Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING now see if more
* readers can be let go.
*/
while ( 1 ) {
next = _Thread_queue_First( &the_rwlock->Wait_queue );
if ( !next )
return CORE_RWLOCK_SUCCESSFUL;
if ( next->Wait.option != CORE_RWLOCK_THREAD_WAITING_FOR_READ )
return CORE_RWLOCK_SUCCESSFUL;
/* it is definitely wanting to read */
the_rwlock->number_of_readers += 1;
_Thread_queue_Extract( &the_rwlock->Wait_queue, next );
}
/*
* Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING now see if more
* readers can be let go.
*/
while ( 1 ) {
next = _Thread_queue_First( &the_rwlock->Wait_queue );
if ( !next )
return CORE_RWLOCK_SUCCESSFUL;
if ( next->Wait.option != CORE_RWLOCK_THREAD_WAITING_FOR_READ )
return CORE_RWLOCK_SUCCESSFUL;
/* it is definitely wanting to read */
the_rwlock->number_of_readers += 1;
_Thread_queue_Extract( &the_rwlock->Wait_queue, next );
}
/* XXX need to put read/write lock request indicator in Wait info */
}
return CORE_RWLOCK_SUCCESSFUL;
}