always unlock the mutex in case of failure

This commit is contained in:
krangelov
2021-10-26 10:22:29 +02:00
parent fd40c204e2
commit a607799bb3

View File

@@ -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);