diff options
Diffstat (limited to 'resource')
-rw-r--r-- | resource/csdk/connectivity/common/src/cathreadpool_pthreads.c | 10 |
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 *) |