Changeset dfdad6ab in rtems


Ignore:
Timestamp:
Oct 8, 2014, 8:09:14 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
b9f95225
Parents:
419accf
git-author:
Sebastian Huber <sebastian.huber@…> (10/08/14 08:09:14)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/08/14 09:26:27)
Message:

posix: Fix mutex auto initialization

Use the once lock to prevent race conditions during auto initialization.

File:
1 edited

Legend:

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

    r419accf rdfdad6ab  
    2020
    2121#include <rtems/posix/muteximpl.h>
     22#include <rtems/score/apimutex.h>
    2223
    2324static bool _POSIX_Mutex_Check_id_and_auto_init(
     
    3536    int eno;
    3637
    37     eno = pthread_mutex_init( mutex, NULL );
     38    _Once_Lock();
     39
     40    if ( *mutex == PTHREAD_MUTEX_INITIALIZER ) {
     41      eno = pthread_mutex_init( mutex, NULL );
     42    } else {
     43      eno = 0;
     44    }
     45
     46    _Once_Unlock();
    3847
    3948    if ( eno != 0 ) {
Note: See TracChangeset for help on using the changeset viewer.