Skip to content

Commit

Permalink
add missing mutex unlock at early exit rtThreadPool (#236)
Browse files Browse the repository at this point in the history
Co-authored-by: Karunakaran A <[email protected]>
  • Loading branch information
NetajiPanigrahi and karuna2git authored Nov 20, 2024
1 parent bcd811c commit 64b895e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/rtmessage/rtThreadPool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 64b895e

Please sign in to comment.