From 6f68e7b50e0bb837d02dc2cb8a7bc5887534d7b8 Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 20 Dec 2001 15:23:01 +0000 Subject: * mutex.c (pthread_mutex_lock): Decrementing lock_idx was not thread-safe. (pthread_mutex_trylock): Likewise. --- mutex.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mutex.c') diff --git a/mutex.c b/mutex.c index 0009428..e62647e 100644 --- a/mutex.c +++ b/mutex.c @@ -650,7 +650,7 @@ pthread_mutex_lock(pthread_mutex_t *mutex) if( mx->kind != PTHREAD_MUTEX_FAST_NP && pthread_equal( mx->ownerThread, pthread_self() ) ) { - mx->lock_idx--; + (void) InterlockedDecrement( &mx->lock_idx ); if( mx->kind == PTHREAD_MUTEX_RECURSIVE_NP ) { @@ -766,7 +766,7 @@ pthread_mutex_trylock(pthread_mutex_t *mutex) } else { - mx->lock_idx--; + (void) InterlockedDecrement( &mx->lock_idx ); result = EBUSY; } @@ -780,3 +780,4 @@ pthread_mutex_trylock(pthread_mutex_t *mutex) return(result); } + -- cgit v1.2.3