From: Chenghai Huang huangchenghai2@huawei.com
When the num of recv packets is greater than the expected number. The condition that expected nums equal to actual nums, for exiting the poll loop will cause a long retry loop.
Therefore, the loop exit condition is modified, and full_sem is reduced when no task needs to be queried.
Signed-off-by: Chenghai Huang huangchenghai2@huawei.com --- src/uadk_async.c | 6 ++++-- src/uadk_cipher.c | 2 +- src/uadk_prov_cipher.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/uadk_async.c b/src/uadk_async.c index a36a394..04e52f8 100644 --- a/src/uadk_async.c +++ b/src/uadk_async.c @@ -322,7 +322,7 @@ static void *async_poll_process_func(void *args) { struct async_poll_task *task; struct async_op *op; - int ret, idx; + int ret, idx, empty_num;
while (uadk_e_get_async_poll_state()) { if (sem_wait(&poll_queue.full_sem)) { @@ -334,7 +334,9 @@ static void *async_poll_process_func(void *args)
task = async_get_queue_task(); if (!task) { - (void)sem_post(&poll_queue.full_sem); + (void)sem_getvalue(&poll_queue.empty_sem, &empty_num); + if (empty_num != ASYNC_QUEUE_TASK_NUM) + (void)sem_post(&poll_queue.full_sem); usleep(1); continue; } diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c index ff53e0b..44b0aa0 100644 --- a/src/uadk_cipher.c +++ b/src/uadk_cipher.c @@ -362,7 +362,7 @@ static int uadk_e_cipher_env_poll(void *ctx)
do { ret = wd_cipher_poll(expt, &recv); - if (ret < 0 || recv == expt) + if (ret < 0 || recv >= expt) return ret; rx_cnt++; } while (rx_cnt < ENGINE_ENV_RECV_MAX_CNT); diff --git a/src/uadk_prov_cipher.c b/src/uadk_prov_cipher.c index 69cd114..70e9e89 100644 --- a/src/uadk_prov_cipher.c +++ b/src/uadk_prov_cipher.c @@ -257,7 +257,7 @@ static int uadk_cipher_poll(void *ctx)
do { ret = wd_cipher_poll(expt, &recv); - if (ret < 0 || recv == expt) + if (ret < 0 || recv >= expt) return ret; rx_cnt++; } while (rx_cnt < ENGINE_RECV_MAX_CNT);