From 816c7371b1152ed340525b2fad16bbe2686e754c Mon Sep 17 00:00:00 2001 From: Netaji Panigrahi <114923459+NetajiPanigrahi@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:47:39 +0530 Subject: [PATCH] add missing mutex unlock at early exit rtThreadPool --- src/rtmessage/rtThreadPool.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rtmessage/rtThreadPool.c b/src/rtmessage/rtThreadPool.c index 79d5502e..8a9785a5 100644 --- a/src/rtmessage/rtThreadPool.c +++ b/src/rtmessage/rtThreadPool.c @@ -304,7 +304,10 @@ rtError rtThreadPool_RunTask(rtThreadPool pool, rtThreadPoolFunc func, void* use { task = rt_try_malloc(sizeof(struct _rtThreadTask)); if(!task) - return rtErrorFromErrno(ENOMEM); + { + pthread_mutex_unlock(&pool->poolLock); + return rtErrorFromErrno(ENOMEM); + } rtLog_Debug("taskList data null so alloc new %p", (void*)task); rtListItem_SetData(item, task); } @@ -321,7 +324,10 @@ rtError rtThreadPool_RunTask(rtThreadPool pool, rtThreadPoolFunc func, void* use { rtLog_Debug("%s creating new thread", __FUNCTION__); if((err = rtThreadPool_CreateWorkerThread(pool)) != RT_OK) - return err; + { + pthread_mutex_unlock(&pool->poolLock); + return err; + } if(pool->threadCount == pool->maxThreadCount - 1) rtLog_Debug("%s reached max thread count %zu", __FUNCTION__, pool->maxThreadCount); }