From cb8b53b9961543d9069284eedbe89abfc1d7713b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 27 Nov 2011 18:39:25 +0100 Subject: Fix __mutex_unlock_solid safety libc releases the spinlock before calling __mutex_unlock_solid, so we have to try to reacquire it before possibly giving it to some blocked thread. * pthread/cthreads-compat.c (__mutex_unlock_solid): Call __pthread_spin_trylock before calling __pthread_mutex_unlock. --- pthread/cthreads-compat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pthread/cthreads-compat.c b/pthread/cthreads-compat.c index e0536ef2..cbe8170e 100644 --- a/pthread/cthreads-compat.c +++ b/pthread/cthreads-compat.c @@ -100,5 +100,8 @@ __mutex_lock_solid (void *lock) void __mutex_unlock_solid (void *lock) { + if (__pthread_spin_trylock (lock) != 0) + /* Somebody already got the lock, that one will manage waking up others */ + return; __pthread_mutex_unlock (lock); } -- cgit v1.2.3