From 4db19b521546c7edd4034a31af4b1982f1a31e4c Mon Sep 17 00:00:00 2001 From: factosea <285808407@qq.com> Date: Tue, 14 May 2024 17:03:22 +0800 Subject: [PATCH] destory --- source/os/src/osSemaphore.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/source/os/src/osSemaphore.c b/source/os/src/osSemaphore.c index 8f315238c8..12f6c5bf58 100644 --- a/source/os/src/osSemaphore.c +++ b/source/os/src/osSemaphore.c @@ -219,11 +219,25 @@ int tsem_init(tsem_t* sem, int pshared, unsigned int value) { int ret = taosThreadMutexInit(&sem->mutex, NULL); if (ret != 0) return ret; ret = taosThreadCondAttrInit(&sem->attr); - if (ret != 0) return ret; + if (ret != 0) + { + taosThreadMutexDestroy(&sem->mutex); + return ret; + } ret = taosThreadCondAttrSetclock(&sem->attr, CLOCK_MONOTONIC); - if (ret != 0) return ret; + if (ret != 0) + { + taosThreadMutexDestroy(&sem->mutex); + taosThreadCondAttrDestroy(&sem->attr); + return ret; + } ret = taosThreadCondInit(&sem->cond, &sem->attr); - if (ret != 0) return ret; + if (ret != 0) + { + taosThreadMutexDestroy(&sem->mutex); + taosThreadCondAttrDestroy(&sem->attr); + return ret; + } sem->count = value; return 0; @@ -238,12 +252,10 @@ int tsem_post(tsem_t *sem) { } int tsem_destroy(tsem_t* sem) { - int ret = taosThreadMutexDestroy(&sem->mutex); - if (ret != 0) return ret; - ret = taosThreadCondDestroy(&sem->cond); - return ret; - ret = taosThreadCondAttrDestroy(&sem->attr); - return ret; + taosThreadMutexDestroy(&sem->mutex); + taosThreadCondDestroy(&sem->cond); + taosThreadCondAttrDestroy(&sem->attr); + return 0; } int32_t tsem_wait(tsem_t* sem) {