From 108fcc1142ad5d087978190dbd7dd782e9b17d1d Mon Sep 17 00:00:00 2001 From: "Zhang, Yanmin" Date: Mon, 4 Feb 2008 09:17:52 +0100 Subject: [PATCH] Fix bug in fio mutex initialization Fio sem->cond isn't initialized properly. Signed-off-by: Jens Axboe --- mutex.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mutex.c b/mutex.c index be3258df..17e62c9f 100644 --- a/mutex.c +++ b/mutex.c @@ -19,6 +19,7 @@ struct fio_sem *fio_sem_init(int value) char sem_name[] = "/tmp/.fio_sem.XXXXXX"; struct fio_sem *sem = NULL; pthread_mutexattr_t attr; + pthread_condattr_t cond; int fd; fd = mkstemp(sem_name); @@ -53,6 +54,11 @@ struct fio_sem *fio_sem_init(int value) perror("pthread_mutexattr_setpshared"); goto err; } + + pthread_condattr_init(&cond); + pthread_condattr_setpshared(&cond, PTHREAD_PROCESS_SHARED); + pthread_cond_init(&sem->cond, &cond); + if (pthread_mutex_init(&sem->lock, &attr)) { perror("pthread_mutex_init"); goto err; -- 2.25.1