Changeset 90f1265 in rtems


Ignore:
Timestamp:
Apr 18, 2016, 4:23:27 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
ca18cb59
Parents:
928d455
git-author:
Sebastian Huber <sebastian.huber@…> (04/18/16 04:23:27)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/21/16 05:29:38)
Message:

score: Fix _CORE_semaphore_Flush()

Use proper CORE_semaphore_Status for _CORE_semaphore_Flush() and
_CORE_semaphore_Destroy() operations.

Close #2696.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/include/rtems/posix/semaphoreimpl.h

    r928d455 r90f1265  
    5959)
    6060{
    61   _CORE_semaphore_Destroy( &the_semaphore->Semaphore );
    6261  _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object );
    6362}
  • cpukit/posix/src/semaphorecreatesupp.c

    r928d455 r90f1265  
    5555    rtems_set_errno_and_return_minus_one( ENOSYS );
    5656
    57   the_semaphore = _POSIX_Semaphore_Allocate_unprotected();
    58   if ( !the_semaphore ) {
    59     rtems_set_errno_and_return_minus_one( ENOSPC );
    60   }
    61 
    6257  /*
    6358   * Make a copy of the user's string for name just in case it was
     
    6762    name = _Workspace_String_duplicate( name_arg, name_len );
    6863    if ( !name ) {
    69       _POSIX_Semaphore_Free( the_semaphore );
    7064      rtems_set_errno_and_return_minus_one( ENOMEM );
    7165    }
    7266  } else {
    7367    name = NULL;
     68  }
     69
     70  the_semaphore = _POSIX_Semaphore_Allocate_unprotected();
     71  if ( !the_semaphore ) {
     72    _Workspace_Free( name );
     73    rtems_set_errno_and_return_minus_one( ENOSPC );
    7474  }
    7575
  • cpukit/posix/src/semaphoredeletesupp.c

    r928d455 r90f1265  
    3737  if ( !the_semaphore->linked && !the_semaphore->open_count ) {
    3838    _Objects_Close( &_POSIX_Semaphore_Information, &the_semaphore->Object );
    39     _CORE_semaphore_Flush( &the_semaphore->Semaphore, -1, NULL, 0 );
     39    _CORE_semaphore_Destroy( &the_semaphore->Semaphore, NULL, 0 );
    4040    _POSIX_Semaphore_Free( the_semaphore );
    4141  }
  • cpukit/posix/src/semaphoretranslatereturncode.c

    r928d455 r90f1265  
    2626  0,                   /* CORE_SEMAPHORE_STATUS_SUCCESSFUL */
    2727  EAGAIN,              /* CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT */
    28   EAGAIN,              /* CORE_SEMAPHORE_WAS_DELETED */
     28  EINVAL,              /* CORE_SEMAPHORE_WAS_DELETED */
    2929  ETIMEDOUT,           /* CORE_SEMAPHORE_TIMEOUT */
    3030  /* The next error can not occur since we set the maximum
  • cpukit/rtems/src/semdelete.c

    r928d455 r90f1265  
    7474        _CORE_mutex_Destroy( &the_semaphore->Core_control.mutex );
    7575      } else {
    76         _CORE_semaphore_Flush(
     76        _CORE_semaphore_Destroy(
    7777          &the_semaphore->Core_control.semaphore,
    78           CORE_SEMAPHORE_WAS_DELETED,
    7978          _Semaphore_MP_Send_object_was_deleted,
    8079          id
    8180        );
    82         _CORE_semaphore_Destroy( &the_semaphore->Core_control.semaphore );
    8381      }
    8482
  • cpukit/rtems/src/semflush.c

    r928d455 r90f1265  
    6161        _CORE_semaphore_Flush(
    6262          &the_semaphore->Core_control.semaphore,
    63           CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT,
    6463          _Semaphore_MP_Send_object_was_deleted,
    6564          id
  • cpukit/score/include/rtems/score/coresemimpl.h

    r928d455 r90f1265  
    8787);
    8888
    89 RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy(
    90   CORE_semaphore_Control *the_semaphore
    91 )
    92 {
    93   _Thread_queue_Destroy( &the_semaphore->Wait_queue );
    94 }
     89#define _CORE_semaphore_Destroy( \
     90  the_semaphore, \
     91  mp_callout, \
     92  mp_id \
     93) \
     94  do { \
     95    _Thread_queue_Flush( \
     96      &( the_semaphore )->Wait_queue, \
     97      ( the_semaphore )->operations, \
     98      CORE_SEMAPHORE_WAS_DELETED, \
     99      mp_callout, \
     100      mp_id \
     101    ); \
     102    _Thread_queue_Destroy( &( the_semaphore )->Wait_queue ); \
     103  } while ( 0 )
    95104
    96105RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Do_surrender(
     
    181190#define _CORE_semaphore_Flush( \
    182191  the_semaphore, \
    183   status, \
    184192  mp_callout, \
    185193  mp_id \
     
    188196    &( the_semaphore )->Wait_queue, \
    189197    ( the_semaphore )->operations, \
    190     status, \
     198    CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT, \
    191199    mp_callout, \
    192200    mp_id \
  • testsuites/psxtests/psxsem01/init.c

    r928d455 r90f1265  
    2727
    2828#define MAX_SEMS  10
     29
     30static void *sem_wait_task(void *arg)
     31{
     32  sem_t *sem;
     33  int    rv;
     34
     35  sem = arg;
     36
     37  rv = sem_wait( sem );
     38  rtems_test_assert( rv == 0 );
     39
     40  errno = 0;
     41  rv = sem_wait( sem );
     42  rtems_test_assert( rv == -1 );
     43  rtems_test_assert( errno == EINVAL );
     44
     45  return NULL;
     46}
     47
     48static void test_sem_wait_during_delete(void)
     49{
     50  sem_t     sem;
     51  int       rv;
     52  pthread_t th;
     53  int       eno;
     54  int       val;
     55
     56  rv = sem_init( &sem, 0, 1 );
     57  rtems_test_assert( rv == 0 );
     58
     59  eno = pthread_create( &th, NULL, sem_wait_task, &sem );
     60  rtems_test_assert( eno == 0 );
     61
     62  rv = sem_getvalue( &sem, &val );
     63  rtems_test_assert( rv == 0 );
     64  rtems_test_assert( val == 1 );
     65
     66  sched_yield();
     67
     68  rv = sem_getvalue( &sem, &val );
     69  rtems_test_assert( rv == 0 );
     70  rtems_test_assert( val == 0 );
     71
     72  rv = sem_destroy( &sem );
     73  rtems_test_assert( rv == 0 );
     74
     75  eno = pthread_join( th, NULL );
     76  rtems_test_assert( eno == 0 );
     77}
    2978
    3079void *POSIX_Init(
     
    296345  rtems_test_assert( (status == -1) && (errno == ENOENT) );
    297346
     347  test_sem_wait_during_delete();
    298348
    299349  /* Try adding in unlinking before closing... (can we still open?) */
     
    313363#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
    314364
    315 #define CONFIGURE_MAXIMUM_POSIX_THREADS     1
     365#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
    316366#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES  MAX_SEMS
    317367
Note: See TracChangeset for help on using the changeset viewer.