X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=mutex.c;h=e33e7cc8f2611a42256e72a3bceddf9e7560b1ef;hb=034ca7e4b63ff63dee43770c20d0860903705cf3;hp=e148430b618e5cae1c1fd93c1134f47910198ec6;hpb=3b2e1464ae58caf42c74ab4bdeaa5eae7c38a23f;p=fio.git diff --git a/mutex.c b/mutex.c index e148430b..e33e7cc8 100644 --- a/mutex.c +++ b/mutex.c @@ -33,6 +33,10 @@ struct fio_mutex *fio_mutex_init(int value) return NULL; } +#ifdef FIO_HAVE_FALLOCATE + posix_fallocate(fd, 0, sizeof(struct fio_mutex)); +#endif + if (ftruncate(fd, sizeof(struct fio_mutex)) < 0) { perror("ftruncate mutex"); goto err; @@ -65,14 +69,18 @@ struct fio_mutex *fio_mutex_init(int value) log_err("pthread_mutexattr_init: %s\n", strerror(ret)); goto err; } +#ifdef FIO_HAVE_PSHARED_MUTEX ret = pthread_mutexattr_setpshared(&attr, mflag); if (ret) { log_err("pthread_mutexattr_setpshared: %s\n", strerror(ret)); goto err; } +#endif pthread_condattr_init(&cond); +#ifdef FIO_HAVE_PSHARED_MUTEX pthread_condattr_setpshared(&cond, mflag); +#endif pthread_cond_init(&mutex->cond, &cond); ret = pthread_mutex_init(&mutex->lock, &attr); @@ -81,6 +89,9 @@ struct fio_mutex *fio_mutex_init(int value) goto err; } + pthread_condattr_destroy(&cond); + pthread_mutexattr_destroy(&attr); + return mutex; err: if (mutex)