mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
destroy the r/w lock if there is no shared file
This commit is contained in:
@@ -525,6 +525,12 @@ PgfDB::~PgfDB()
|
|||||||
if (ms != NULL) {
|
if (ms != NULL) {
|
||||||
unregister_process();
|
unregister_process();
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
if (fd < 0) {
|
||||||
|
pthread_rwlock_destroy(&ms->rwlock);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t size =
|
size_t size =
|
||||||
ms->top + chunksize(ptr(ms,ms->top)) + sizeof(size_t);
|
ms->top + chunksize(ptr(ms,ms->top)) + sizeof(size_t);
|
||||||
|
|
||||||
@@ -690,13 +696,12 @@ void PgfDB::init_state(size_t size)
|
|||||||
if ((code = pthread_rwlockattr_init(&attr)) != 0) {
|
if ((code = pthread_rwlockattr_init(&attr)) != 0) {
|
||||||
throw pgf_systemerror(code);
|
throw pgf_systemerror(code);
|
||||||
}
|
}
|
||||||
if (fd > 0) {
|
if (fd >= 0) {
|
||||||
if ((code = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) != 0) {
|
if ((code = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) != 0) {
|
||||||
pthread_rwlockattr_destroy(&attr);
|
pthread_rwlockattr_destroy(&attr);
|
||||||
throw pgf_systemerror(code);
|
throw pgf_systemerror(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(&ms->rwlock, 0, sizeof(ms->rwlock));
|
|
||||||
if ((code = pthread_rwlock_init(&ms->rwlock, &attr)) != 0) {
|
if ((code = pthread_rwlock_init(&ms->rwlock, &attr)) != 0) {
|
||||||
pthread_rwlockattr_destroy(&attr);
|
pthread_rwlockattr_destroy(&attr);
|
||||||
throw pgf_systemerror(code);
|
throw pgf_systemerror(code);
|
||||||
|
|||||||
Reference in New Issue
Block a user