Changeset ca18cb59 in rtems


Ignore:
Timestamp:
Apr 18, 2016, 4:53:10 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
8765c57
Parents:
90f1265
git-author:
Sebastian Huber <sebastian.huber@…> (04/18/16 04:53:10)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/21/16 05:29:38)
Message:

score: Close semaphore object before flush

This prevents use of the object after the flush on uni-processor
configurations.

Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/src/semdelete.c

    r90f1265 rca18cb59  
    4949#if defined(RTEMS_SMP)
    5050      if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
    51         MRSP_Status mrsp_status = _MRSP_Destroy(
    52           &the_semaphore->Core_control.mrsp
    53         );
     51        MRSP_Status mrsp_status;
     52
     53        mrsp_status = _MRSP_Can_destroy( &the_semaphore->Core_control.mrsp );
    5454        if ( mrsp_status != MRSP_SUCCESSFUL ) {
    5555          _Objects_Put( &the_semaphore->Object );
     
    5959      } else
    6060#endif
    61       if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
    62         if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) &&
    63              !_Attributes_Is_simple_binary_semaphore( attribute_set ) ) {
    64           _Objects_Put( &the_semaphore->Object );
    65           _Objects_Allocator_unlock();
    66           return RTEMS_RESOURCE_IN_USE;
    67         }
    68         _CORE_mutex_Flush(
    69           &the_semaphore->Core_control.mutex,
    70           CORE_MUTEX_WAS_DELETED,
    71           _Semaphore_MP_Send_object_was_deleted,
    72           id
    73         );
    74         _CORE_mutex_Destroy( &the_semaphore->Core_control.mutex );
    75       } else {
    76         _CORE_semaphore_Destroy(
    77           &the_semaphore->Core_control.semaphore,
    78           _Semaphore_MP_Send_object_was_deleted,
    79           id
    80         );
     61      if (
     62        !_Attributes_Is_counting_semaphore( attribute_set )
     63          && _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex )
     64          && !_Attributes_Is_simple_binary_semaphore( attribute_set )
     65      ) {
     66        _Objects_Put( &the_semaphore->Object );
     67        _Objects_Allocator_unlock();
     68        return RTEMS_RESOURCE_IN_USE;
    8169      }
    8270
     
    9684      }
    9785#endif
     86
     87#if defined(RTEMS_SMP)
     88      if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
     89        _MRSP_Destroy( &the_semaphore->Core_control.mrsp );
     90      } else
     91#endif
     92      if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
     93        _CORE_mutex_Flush(
     94          &the_semaphore->Core_control.mutex,
     95          CORE_MUTEX_WAS_DELETED,
     96          _Semaphore_MP_Send_object_was_deleted,
     97          id
     98        );
     99        _CORE_mutex_Destroy( &the_semaphore->Core_control.mutex );
     100      } else {
     101        _CORE_semaphore_Destroy(
     102          &the_semaphore->Core_control.semaphore,
     103          _Semaphore_MP_Send_object_was_deleted,
     104          id
     105        );
     106      }
    98107
    99108      _Objects_Put( &the_semaphore->Object );
  • cpukit/score/include/rtems/score/mrspimpl.h

    r90f1265 rca18cb59  
    399399}
    400400
    401 RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Destroy( MRSP_Control *mrsp )
     401RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Can_destroy( MRSP_Control *mrsp )
    402402{
    403403  if ( _Resource_Get_owner( &mrsp->Resource ) != NULL ) {
     
    405405  }
    406406
     407  return MRSP_SUCCESSFUL;
     408}
     409
     410RTEMS_INLINE_ROUTINE void _MRSP_Destroy( MRSP_Control *mrsp )
     411{
    407412  _ISR_lock_Destroy( &mrsp->Lock );
    408413  _Workspace_Free( mrsp->ceiling_priorities );
    409 
    410   return MRSP_SUCCESSFUL;
    411414}
    412415
Note: See TracChangeset for help on using the changeset viewer.