1. Modify unreachable return logic in async_poll_process_func. Use global variable to control the async poll progress. 2. Add static attribute of ecc_res_config.
Signed-off-by: Zhiqi Song songzhiqi1@huawei.com --- src/uadk_async.c | 22 +++++++++++++++++++--- src/uadk_async.h | 7 ++++++- src/uadk_pkey.c | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/src/uadk_async.c b/src/uadk_async.c index 2edd6ea..f21eabb 100644 --- a/src/uadk_async.c +++ b/src/uadk_async.c @@ -26,8 +26,20 @@
static struct async_poll_queue poll_queue;
+static int g_uadk_e_keep_polling; + static async_recv_t async_recv_func[ASYNC_TASK_MAX];
+static int uadk_e_get_async_poll_state(void) +{ + return g_uadk_e_keep_polling; +} + +static void uadk_e_set_async_poll_state(int state) +{ + g_uadk_e_keep_polling = state; +} + static void async_fd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key, OSSL_ASYNC_FD readfd, void *custom) { @@ -114,6 +126,9 @@ static void async_poll_task_free(void) OPENSSL_free(task);
poll_queue.head = NULL; + + uadk_e_set_async_poll_state(DISABLE_ASYNC_POLLING); + pthread_mutex_unlock(&poll_queue.async_task_mutex); sem_destroy(&poll_queue.empty_sem); sem_destroy(&poll_queue.full_sem); @@ -308,7 +323,7 @@ static void *async_poll_process_func(void *args) struct async_op *op; int ret, idx;
- while (1) { + while (uadk_e_get_async_poll_state()) { if (sem_wait(&poll_queue.full_sem) != 0) { if (errno == EINTR) { /* sem_wait is interrupted by interrupt, continue */ @@ -354,13 +369,14 @@ int async_module_init(void) memset(poll_queue.head, 0, sizeof(struct async_poll_task) * ASYNC_QUEUE_TASK_NUM);
- if (sem_init(&poll_queue.empty_sem, 0, - ASYNC_QUEUE_TASK_NUM) != 0) + if (sem_init(&poll_queue.empty_sem, 0, ASYNC_QUEUE_TASK_NUM) != 0) goto err;
if (sem_init(&poll_queue.full_sem, 0, 0) != 0) goto err;
+ 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)) diff --git a/src/uadk_async.h b/src/uadk_async.h index 8a4822e..d7a8bb5 100644 --- a/src/uadk_async.h +++ b/src/uadk_async.h @@ -22,7 +22,7 @@ #include <semaphore.h> #include <openssl/async.h>
-#define ASYNC_QUEUE_TASK_NUM 1024 +#define ASYNC_QUEUE_TASK_NUM 1024
struct async_op { ASYNC_JOB *job; @@ -47,6 +47,11 @@ enum task_type { ASYNC_TASK_MAX };
+enum poll_state { + DISABLE_ASYNC_POLLING, + ENABLE_ASYNC_POLLING +}; + struct async_poll_task { enum task_type type; void *ctx; diff --git a/src/uadk_pkey.c b/src/uadk_pkey.c index 8532b88..ba33b7d 100644 --- a/src/uadk_pkey.c +++ b/src/uadk_pkey.c @@ -128,7 +128,7 @@ static int uadk_ecc_poll(void *ctx) }
/* Make resource configure static */ -struct ecc_res_config ecc_res_config = { +static struct ecc_res_config ecc_res_config = { .sched = { .sched_type = -1, .wd_sched = {