Workaround pthreads-win32 pthread_rwlock_init limitation.
authorBruce Cran <bruce@cran.org.uk>
Fri, 29 Mar 2013 16:17:25 +0000 (16:17 +0000)
committerJens Axboe <axboe@kernel.dk>
Fri, 29 Mar 2013 16:38:08 +0000 (10:38 -0600)
On Windows, pthreads-win32 returns EINVAL if you specify an attribute when
calling pthread_rwlock_init. Work around this by only specifying the attribute
when FIO_HAVE_PSHARED_MUTEX is defined.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
mutex.c

diff --git a/mutex.c b/mutex.c
index d1e3ceaeff3469be1462ed1af7434f44e8760a72..e1fbb607f1a416fb06a25a611f0f4233c9814357 100644 (file)
--- a/mutex.c
+++ b/mutex.c
@@ -205,9 +205,12 @@ struct fio_rwlock *fio_rwlock_init(void)
                log_err("pthread_rwlockattr_setpshared: %s\n", strerror(ret));
                goto destroy_attr;
        }
                log_err("pthread_rwlockattr_setpshared: %s\n", strerror(ret));
                goto destroy_attr;
        }
-#endif
 
        ret = pthread_rwlock_init(&lock->lock, &attr);
 
        ret = pthread_rwlock_init(&lock->lock, &attr);
+#else
+       ret = pthread_rwlock_init(&lock->lock, NULL);
+#endif
+
        if (ret) {
                log_err("pthread_rwlock_init: %s\n", strerror(ret));
                goto destroy_attr;
        if (ret) {
                log_err("pthread_rwlock_init: %s\n", strerror(ret));
                goto destroy_attr;