From: Hao Fang fanghao11@huawei.com
When the pthread exit also need to call async_poll_task_free() to unint thread_attr.
Signed-off-by: Hao Fang fanghao11@huawei.com --- src/uadk_async.c | 8 ++++---- src/uadk_async.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/uadk_async.c b/src/uadk_async.c index 499907b..8cfb651 100644 --- a/src/uadk_async.c +++ b/src/uadk_async.c @@ -132,6 +132,7 @@ void async_poll_task_free(void) poll_queue.head = NULL;
pthread_mutex_unlock(&poll_queue.async_task_mutex); + pthread_attr_destroy(&poll_queue.thread_attr); sem_destroy(&poll_queue.empty_sem); sem_destroy(&poll_queue.full_sem); pthread_mutex_destroy(&poll_queue.async_task_mutex); @@ -359,7 +360,6 @@ static void *async_poll_process_func(void *args) int async_module_init(void) { pthread_t thread_id; - pthread_attr_t thread_attr;
memset(&poll_queue, 0, sizeof(struct async_poll_queue));
@@ -378,9 +378,9 @@ int async_module_init(void)
uadk_e_set_async_poll_state(ENABLE_ASYNC_POLLING);
- pthread_attr_init(&thread_attr); - pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED); - if (pthread_create(&thread_id, &thread_attr, async_poll_process_func, NULL)) + pthread_attr_init(&poll_queue.thread_attr); + pthread_attr_setdetachstate(&poll_queue.thread_attr, PTHREAD_CREATE_DETACHED); + if (pthread_create(&thread_id, &poll_queue.thread_attr, async_poll_process_func, NULL)) goto err;
poll_queue.thread_id = thread_id; diff --git a/src/uadk_async.h b/src/uadk_async.h index 678e392..6857927 100644 --- a/src/uadk_async.h +++ b/src/uadk_async.h @@ -69,6 +69,7 @@ struct async_poll_queue { sem_t full_sem; pthread_mutex_t async_task_mutex; pthread_t thread_id; + pthread_attr_t thread_attr; };
int async_setup_async_event_notification(struct async_op *op);