Changeset 9ec7d492 in rtems


Ignore:
Timestamp:
May 25, 2016, 6:37:28 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
3039e18
Parents:
631b3c8
git-author:
Sebastian Huber <sebastian.huber@…> (05/25/16 06:37:28)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/25/16 10:43:54)
Message:

posix: Fix pthread_spin_unlock() error status

Close #2719.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/pspinlocktranslatereturncode.c

    r631b3c8 r9ec7d492  
    3232  -1,                       /* CORE_SPINLOCK_TIMEOUT */
    3333  EBUSY,                    /* CORE_SPINLOCK_IS_BUSY */
    34   EBUSY,                    /* CORE_SPINLOCK_UNAVAILABLE */
    35   0                         /* CORE_SPINLOCK_NOT_LOCKED */
     34  EBUSY                     /* CORE_SPINLOCK_UNAVAILABLE */
    3635};
    3736
  • cpukit/score/include/rtems/score/corespinlockimpl.h

    r631b3c8 r9ec7d492  
    5959   *  unavailable.
    6060   */
    61   CORE_SPINLOCK_UNAVAILABLE,
    62   /** This status indicates that the spinlock is not currently locked and thus
    63    *  should not be released.
    64    */
    65   CORE_SPINLOCK_NOT_LOCKED
     61  CORE_SPINLOCK_UNAVAILABLE
    6662}   CORE_spinlock_Status;
    6763
    6864/** This is a shorthand for the last status code. */
    69 #define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_NOT_LOCKED
     65#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_UNAVAILABLE
    7066
    7167/** This indicates the lock is available. */
  • cpukit/score/src/corespinlockrelease.c

    r631b3c8 r9ec7d492  
    3030
    3131    /*
    32      *  It must locked before it can be unlocked.
    33      */
    34     if ( the_spinlock->lock == CORE_SPINLOCK_UNLOCKED ) {
    35       _CORE_spinlock_Release( the_spinlock, lock_context );
    36       return CORE_SPINLOCK_NOT_LOCKED;
    37     }
    38 
    39     /*
    4032     *  It must locked by the current thread before it can be unlocked.
    4133     */
    42     if ( the_spinlock->holder != _Thread_Executing ) {
     34    if (
     35      the_spinlock->lock != CORE_SPINLOCK_LOCKED
     36        || the_spinlock->holder != _Thread_Executing
     37    ) {
    4338      _CORE_spinlock_Release( the_spinlock, lock_context );
    4439      return CORE_SPINLOCK_NOT_HOLDER;
  • testsuites/psxtests/psxspin01/psxspin01.scn

    r631b3c8 r9ec7d492  
    1 *** POSIX SPINLOCK TEST 01 ***
     1*** BEGIN OF TEST PSXSPIN 1 ***
    22pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE ) -- EINVAL
    33pthread_spin_init( NULL, PTHREAD_PROCESS_SHARED ) -- EINVAL
     
    1515pthread_spin_unlock( &spinlock ) -- EINVAL
    1616pthread_spin_destroy( &spinlock ) -- EINVAL
    17 pthread_spin_unlock( &Spinlock ) -- already unlocked OK
     17pthread_spin_unlock( &Spinlock ) -- EPERM
    1818pthread_spin_lock( &Spinlock ) -- OK
    1919pthread_spin_lock( &Spinlock ) -- EDEADLK
     
    2424pthread_spin_lock( &Spinlock ) from Thread -- OK
    2525sleep to allow main thread to run
     26pthread_spin_unlock( &Spinlock ) -- EPERM
    2627pthread_spin_lock( &Spinlock ) -- OK
    2728pthread_spin_unlock( &Spinlock ) from Thread -- OK
     
    2930pthread_spin_unlock( &Spinlock ) -- OK
    3031pthread_spin_destroy( &Spinlock ) -- OK
    31 *** END OF POSIX SPINLOCK TEST 01 ***
     32*** END OF TEST PSXSPIN 1 ***
  • testsuites/psxtests/psxspin01/test.c

    r631b3c8 r9ec7d492  
    147147  rtems_test_assert( status == EINVAL );
    148148
    149   puts( "pthread_spin_unlock( &Spinlock ) -- already unlocked OK" );
    150   status = pthread_spin_unlock( &Spinlock );
    151   rtems_test_assert( status == 0 );
     149  puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" );
     150  status = pthread_spin_unlock( &Spinlock );
     151  rtems_test_assert( status == EPERM );
    152152
    153153  /* Now some basic locking and unlocking with a deadlock verification */
     
    201201
    202202  mainThreadSpinning = 1;
     203
     204  puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" );
     205  status = pthread_spin_unlock( &Spinlock );
     206  rtems_test_assert( status == EPERM );
     207
    203208  puts( "pthread_spin_lock( &Spinlock ) -- OK" );
    204209  status = pthread_spin_lock( &Spinlock );
Note: See TracChangeset for help on using the changeset viewer.