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

From: Chenghai Huang <huangchenghai2@huawei.com> The corresponding sending thread can be precisely woken up only after the poll thread receiving succeeds. 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 | 10 ++++++++++ src/uadk_async.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/uadk_async.c b/src/uadk_async.c index 0f92dde..8adc964 100644 --- a/src/uadk_async.c +++ b/src/uadk_async.c @@ -327,6 +327,16 @@ static void *async_poll_process_func(void *args) idx = op->idx; ret = async_recv_func[task->type](task->ctx); if (!poll_queue.is_recv && op->job) { + /* + * Wake up the op->job whose number of polling + * failures exceeds the threshold. + */ + if (ret && ret != -ETIMEDOUT && op->retry++ < ASYNC_MAX_RETRY_CNT) { + (void)sem_post(&poll_queue.full_sem); + continue; + } + + op->retry = 0; op->done = 1; op->ret = ret; (void) async_wake_job(op->job); 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