1
0
forked from GitHub/gf-core

make r/w lock shared only if there is a shared file as well

This commit is contained in:
krangelov
2021-11-16 08:53:22 +01:00
parent c80ef3549c
commit f5e6c695a7

View File

@@ -690,9 +690,11 @@ void PgfDB::init_state(size_t size)
if ((code = pthread_rwlockattr_init(&attr)) != 0) {
throw pgf_systemerror(code);
}
if ((code = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) != 0) {
pthread_rwlockattr_destroy(&attr);
throw pgf_systemerror(code);
if (fd > 0) {
if ((code = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) != 0) {
pthread_rwlockattr_destroy(&attr);
throw pgf_systemerror(code);
}
}
if ((code = pthread_rwlock_init(&ms->rwlock, &attr)) != 0) {
pthread_rwlockattr_destroy(&attr);