[PATCH] uadk_provider: fix the async issue when receive fail

From: Chenghai Huang <huangchenghai2@huawei.com> When a hardware error occurs, asynchronous receiving will reture an abnormal value. In this case, the corresponding sending thread cannot be sure to woken up. Therefore, the counting method is used to wake up the corresponding thread whose number of failures exceeds the threshold. Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> --- src/uadk_async.c | 8 ++++++++ src/uadk_async.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/uadk_async.c b/src/uadk_async.c index 0f92dde..947b4ee 100644 --- a/src/uadk_async.c +++ b/src/uadk_async.c @@ -326,6 +326,14 @@ static void *async_poll_process_func(void *args) op = task->op; idx = op->idx; ret = async_recv_func[task->type](task->ctx); + if (ret && !poll_queue.is_recv) { + if (op->retry++ < ASYNC_MAX_RETRY_CNT) { + (void)sem_post(&poll_queue.full_sem); + continue; + } + op->retry = 0; + } + if (!poll_queue.is_recv && op->job) { op->done = 1; op->ret = ret; diff --git a/src/uadk_async.h b/src/uadk_async.h index 8de3c3c..23f017e 100644 --- a/src/uadk_async.h +++ b/src/uadk_async.h @@ -23,6 +23,7 @@ #include <openssl/async.h> #define ASYNC_QUEUE_TASK_NUM 1024 +#define ASYNC_MAX_RETRY_CNT 1000 #define UADK_E_SUCCESS 1 #define UADK_E_FAIL 0 #define DO_SYNC 1 @@ -32,6 +33,7 @@ struct async_op { int done; int idx; int ret; + int retry; }; struct uadk_e_cb_info { -- 2.33.0
participants (1)
-
Qi Tao