From a01495644a0e2423bf5ae2186e01d7850cb828b0 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Fri, 7 Jun 2024 12:20:30 +0800 Subject: [PATCH] Make various lock guard deinit explicitly callable so that locks can be released manually. --- libs/utils/include/celix_threads.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/utils/include/celix_threads.h b/libs/utils/include/celix_threads.h index 612c1869e..45c3111f1 100644 --- a/libs/utils/include/celix_threads.h +++ b/libs/utils/include/celix_threads.h @@ -22,6 +22,7 @@ #include #include +#include #include "celix_cleanup.h" #include "celix_errno.h" @@ -141,8 +142,8 @@ static CELIX_UNUSED inline celix_mutex_lock_guard_t celixMutexLockGuard_init(cel static CELIX_UNUSED inline void celixMutexLockGuard_deinit(celix_mutex_lock_guard_t* guard) { if (guard->mutex) { celixThreadMutex_unlock(guard->mutex); + guard->mutex = NULL; } - guard->mutex = NULL; } CELIX_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(celix_mutex_lock_guard_t, celixMutexLockGuard_deinit) @@ -216,6 +217,7 @@ static CELIX_UNUSED inline celix_rwlock_wlock_guard_t celixRwlockWlockGuard_init static CELIX_UNUSED inline void celixRwlockWlockGuard_deinit(celix_rwlock_wlock_guard_t* guard) { if (guard->lock) { celixThreadRwlock_unlock(guard->lock); + guard->lock = NULL; } } @@ -263,6 +265,7 @@ static CELIX_UNUSED inline celix_rwlock_rlock_guard_t celixRwlockRlockGuard_init static CELIX_UNUSED inline void celixRwlockRlockGuard_deinit(celix_rwlock_rlock_guard_t* guard) { if (guard->lock) { celixThreadRwlock_unlock(guard->lock); + guard->lock = NULL; } }