projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'adjusting-libpmem' of https://github.com/lukaszstolarczuk/fio into...
[fio.git]
/
pshared.c
diff --git
a/pshared.c
b/pshared.c
index 211925564b9fb543e4edf1d4c6a26df4bd60db21..182a36529df70acbd9b254a00444c2eacc02c2c6 100644
(file)
--- a/
pshared.c
+++ b/
pshared.c
@@
-39,7
+39,11
@@
int cond_init_pshared(pthread_cond_t *cond)
return 0;
}
return 0;
}
-int mutex_init_pshared(pthread_mutex_t *mutex)
+/*
+ * 'type' must be a mutex type, e.g. PTHREAD_MUTEX_NORMAL,
+ * PTHREAD_MUTEX_ERRORCHECK, PTHREAD_MUTEX_RECURSIVE or PTHREAD_MUTEX_DEFAULT.
+ */
+int mutex_init_pshared_with_type(pthread_mutex_t *mutex, int type)
{
pthread_mutexattr_t mattr;
int ret;
{
pthread_mutexattr_t mattr;
int ret;
@@
-51,7
+55,7
@@
int mutex_init_pshared(pthread_mutex_t *mutex)
}
/*
}
/*
- * Not all platforms support process shared mutexes (
Free
BSD)
+ * Not all platforms support process shared mutexes (
NetBSD/Open
BSD)
*/
#ifdef CONFIG_PSHARED
ret = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
*/
#ifdef CONFIG_PSHARED
ret = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
@@
-60,15
+64,26
@@
int mutex_init_pshared(pthread_mutex_t *mutex)
return ret;
}
#endif
return ret;
}
#endif
+ ret = pthread_mutexattr_settype(&mattr, type);
+ if (ret) {
+ log_err("pthread_mutexattr_settype: %s\n", strerror(ret));
+ return ret;
+ }
ret = pthread_mutex_init(mutex, &mattr);
if (ret) {
log_err("pthread_mutex_init: %s\n", strerror(ret));
return ret;
}
ret = pthread_mutex_init(mutex, &mattr);
if (ret) {
log_err("pthread_mutex_init: %s\n", strerror(ret));
return ret;
}
+ pthread_mutexattr_destroy(&mattr);
return 0;
}
return 0;
}
+int mutex_init_pshared(pthread_mutex_t *mutex)
+{
+ return mutex_init_pshared_with_type(mutex, PTHREAD_MUTEX_DEFAULT);
+}
+
int mutex_cond_init_pshared(pthread_mutex_t *mutex, pthread_cond_t *cond)
{
int ret;
int mutex_cond_init_pshared(pthread_mutex_t *mutex, pthread_cond_t *cond)
{
int ret;