• unknown's avatar
    Bug#30992 Wrong implementation of pthread_mutex_trylock() · 662fb20f
    unknown authored
    It's not possible to use WaitForSingleObject to wait
    on a CRITICAL_SECTION, instead use the TryEnterCriticalSection function.
     - if "mutex" was already taken => return EBUSY
     - if "mutex" was aquired => return 0
    
    
    include/config-win.h:
      Make windows.h define TryEnterCriticalSection
    mysys/my_winthread.c:
      Use the TryEnterCriticalSection function to implement pthread_mutex_trylock
      Prevent recursive behaviour by looking at the RecursionCount variable
      in the CRITICAL_SECTION struct and return EBUSY from function if
      the mutex was already locked once.
    662fb20f
config-win.h 12.8 KB