mutex: ensure that fio_mutex_up() holds mutex lock during wakeup
[fio.git] / mutex.c
diff --git a/mutex.c b/mutex.c
index 63229eda09d62084f2b3e7a4cb076fcdf2e0dc88..acc88dc33b98f0b7bb015df7676a15de6e16eb28 100644 (file)
--- a/mutex.c
+++ b/mutex.c
@@ -240,10 +240,11 @@ void fio_mutex_up(struct fio_mutex *mutex)
        if (!mutex->value && mutex->waiters)
                do_wake = 1;
        mutex->value++;
-       pthread_mutex_unlock(&mutex->lock);
 
        if (do_wake)
                pthread_cond_signal(&mutex->cond);
+
+       pthread_mutex_unlock(&mutex->lock);
 }
 
 void fio_rwlock_write(struct fio_rwlock *lock)