mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
always unlock the mutex in case of failure
This commit is contained in:
@@ -203,12 +203,17 @@ pthread_rwlock_t *ipc_new_file_rwlock(const char* file_path)
|
||||
|
||||
pthread_rwlockattr_t attr;
|
||||
if (pthread_rwlockattr_init(&attr) != 0) {
|
||||
pthread_mutex_unlock(&locks->mutex);
|
||||
ipc_error();
|
||||
}
|
||||
if (pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED) != 0) {
|
||||
pthread_rwlockattr_destroy(&attr);
|
||||
pthread_mutex_unlock(&locks->mutex);
|
||||
ipc_error();
|
||||
}
|
||||
if (pthread_rwlock_init(&entry->rwlock, &attr) != 0) {
|
||||
pthread_rwlockattr_destroy(&attr);
|
||||
pthread_mutex_unlock(&locks->mutex);
|
||||
ipc_error();
|
||||
}
|
||||
pthread_rwlockattr_destroy(&attr);
|
||||
|
||||
Reference in New Issue
Block a user