Changeset e0bb60b in rtems


Ignore:
Timestamp:
May 27, 2016, 8:17:28 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
dbd6550
Parents:
bac50cfc
git-author:
Sebastian Huber <sebastian.huber@…> (05/27/16 08:17:28)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/30/16 14:16:22)
Message:

posix: Avoid use of internal mutex methods

Avoid use of internal mutex methods for condition variables.

File:
1 edited

Legend:

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

    rbac50cfc re0bb60b  
    2020
    2121#include <rtems/posix/condimpl.h>
    22 #include <rtems/posix/muteximpl.h>
    2322#include <rtems/posix/posixapi.h>
    2423#include <rtems/score/assert.h>
     
    3736{
    3837  POSIX_Condition_variables_Control *the_cond;
    39   POSIX_Mutex_Control               *the_mutex;
    4038  Thread_queue_Context               queue_context;
    4139  int                                error;
    4240  int                                mutex_error;
    43   Status_Control                     status;
    4441  Per_CPU_Control                   *cpu_self;
    4542  Thread_Control                    *executing;
     
    7067  executing = _Per_CPU_Get_executing( cpu_self );
    7168
    72   /*
    73    *  Historically, we ignored the unlock status since the behavior
    74    *  is undefined by POSIX. But GNU/Linux returns EPERM in this
    75    *  case, so we follow their lead.
    76    */
    77 
    78   the_mutex = _POSIX_Mutex_Get_no_protection( mutex );
    79   if (
    80     the_mutex == NULL
    81       || !_CORE_mutex_Is_owner( &the_mutex->Mutex, executing )
    82   ) {
    83     _POSIX_Condition_variables_Release( the_cond, &queue_context );
    84     _Thread_Dispatch_enable( cpu_self );
    85     return EPERM;
    86   }
    87 
    8869  if ( !already_timedout ) {
    8970    _Thread_queue_Context_set_expected_level( &queue_context, 2 );
     
    10182  }
    10283
    103   _ISR_lock_ISR_disable( &queue_context.Lock_context );
    104   status = _CORE_mutex_Surrender( &the_mutex->Mutex, &queue_context );
    105   _Assert( status == STATUS_SUCCESSFUL );
    106   (void) status;
     84  mutex_error = pthread_mutex_unlock( mutex );
     85  if ( mutex_error != 0 ) {
     86    /*
     87     *  Historically, we ignored the unlock status since the behavior
     88     *  is undefined by POSIX. But GNU/Linux returns EPERM in this
     89     *  case, so we follow their lead.
     90     */
     91    _Assert( mutex_error == EINVAL || mutex_error == EPERM );
     92    _Thread_queue_Extract( executing );
     93    _Thread_Dispatch_enable( cpu_self );
     94    return EPERM;
     95  }
    10796
    10897  /*
     
    133122  mutex_error = pthread_mutex_lock( mutex );
    134123  if ( mutex_error != 0 ) {
     124    _Assert( mutex_error == EINVAL );
    135125    return EINVAL;
    136126  }
Note: See TracChangeset for help on using the changeset viewer.