summaryrefslogtreecommitdiff
path: root/resource
diff options
context:
space:
mode:
authorKush <kush.agrawal@samsung.com>2020-03-02 18:16:29 +0530
committerDoHyun Pyun <dh79.pyun@samsung.com>2020-04-01 10:32:04 +0900
commit5d8046c67a4e3090d89440143560b121c948e8c5 (patch)
tree9aa7463639d03dc4ead9ff183a071950e5adb327 /resource
parent7732d41241f88836aaa948919c7fd4b3120cc969 (diff)
downloadiotivity-5d8046c67a4e3090d89440143560b121c948e8c5.tar.gz
iotivity-5d8046c67a4e3090d89440143560b121c948e8c5.tar.bz2
iotivity-5d8046c67a4e3090d89440143560b121c948e8c5.zip
[CONPRO-1558] Adding check for tasks already freed through ca_thread_pool_free
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/667 (cherry-picked from 2977211f5c3927ac9613688e37cc4cd06e44f1d6) Change-Id: Ie7dd756317d1cab004861c7b85aa9822e94b4b0d Signed-off-by: Kush <kush.agrawal@samsung.com> Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
Diffstat (limited to 'resource')
-rw-r--r--resource/csdk/connectivity/common/src/cathreadpool_pthreads.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/resource/csdk/connectivity/common/src/cathreadpool_pthreads.c b/resource/csdk/connectivity/common/src/cathreadpool_pthreads.c
index 7bb19dd54..f1bb5c25a 100644
--- a/resource/csdk/connectivity/common/src/cathreadpool_pthreads.c
+++ b/resource/csdk/connectivity/common/src/cathreadpool_pthreads.c
@@ -50,6 +50,7 @@ typedef struct ca_thread_pool_details_t
{
u_arraylist_t* threads_list;
oc_mutex list_lock;
+ bool isFree;
} ca_thread_pool_details_t;
/**
@@ -135,6 +136,8 @@ CAResult_t ca_thread_pool_init(int32_t num_of_threads, ca_thread_pool_t *thread_
goto exit;
}
+ (*thread_pool)->details->isFree = false;
+
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
@@ -232,6 +235,11 @@ CAResult_t ca_thread_pool_remove_task(ca_thread_pool_t thread_pool, uint32_t tas
return CA_STATUS_FAILED;
}
+ if(thread_pool->details->isFree){
+ OIC_LOG(INFO, TAG, "thread pool tasks already freed");
+ return CA_STATUS_OK;
+ }
+
oc_mutex_lock(thread_pool->details->list_lock);
for (uint32_t i = 0; i < u_arraylist_length(thread_pool->details->threads_list); ++i)
{
@@ -272,6 +280,8 @@ void ca_thread_pool_free(ca_thread_pool_t thread_pool)
oc_mutex_lock(thread_pool->details->list_lock);
+ thread_pool->details->isFree = true;
+
for (uint32_t i = 0; i < u_arraylist_length(thread_pool->details->threads_list); ++i)
{
ca_thread_pool_thread_info_t *threadInfo = (ca_thread_pool_thread_info_t *)