From 9817d6c8ae773f71f38c6d275a6ce09a306c3670 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Fri, 6 Aug 2021 15:55:04 +0800 Subject: [PATCH 1/2] solve the problem of endless loop --- core/adapter/syscall/src/hdf_syscall_adapter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/adapter/syscall/src/hdf_syscall_adapter.c b/core/adapter/syscall/src/hdf_syscall_adapter.c index d84ea8634..7b3fc9ba6 100644 --- a/core/adapter/syscall/src/hdf_syscall_adapter.c +++ b/core/adapter/syscall/src/hdf_syscall_adapter.c @@ -608,8 +608,8 @@ static void HdfDevListenerThreadDestroy(struct HdfDevListenerThread *thread) HDF_LOGE("%s:failed to exit listener thread with ioctl, will go async way", __func__); return; } - while (thread->status != LISTENER_EXITED) { - OsalUSleep(1); + if (thread->status != LISTENER_EXITED) { + OsalUSleep(100); } HDF_LOGI("poll thread exited"); HdfDevListenerThreadFree(thread); -- Gitee From 6847ed5dc72291e64e3a4e0dff1692494b164ced Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 9 Aug 2021 10:06:53 +0800 Subject: [PATCH 2/2] solve the problem of the endless loop Signed-off-by: YOUR_NAME --- core/adapter/syscall/src/hdf_syscall_adapter.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/adapter/syscall/src/hdf_syscall_adapter.c b/core/adapter/syscall/src/hdf_syscall_adapter.c index 7b3fc9ba6..8950b4868 100644 --- a/core/adapter/syscall/src/hdf_syscall_adapter.c +++ b/core/adapter/syscall/src/hdf_syscall_adapter.c @@ -28,6 +28,7 @@ #define EVENT_READ_BUFF_MAX (20 * 1024) // 20k #define SYSCALL_INVALID_FD (-1) #define HDF_PFD_GROW_SIZE 4 +#define HDF_HK_UNIT 100000 static bool HaveOnlyOneElement(const struct DListHead *head) { @@ -589,6 +590,7 @@ static void HdfDevListenerThreadDestroy(struct HdfDevListenerThread *thread) switch (thread->status) { case LISTENER_RUNNING: { + int count = 0; uint32_t stopCount = 0; OsalMutexLock(&thread->mutex); thread->adapter = NULL; @@ -608,8 +610,9 @@ static void HdfDevListenerThreadDestroy(struct HdfDevListenerThread *thread) HDF_LOGE("%s:failed to exit listener thread with ioctl, will go async way", __func__); return; } - if (thread->status != LISTENER_EXITED) { - OsalUSleep(100); + while (thread->status != LISTENER_EXITED && count <= HDF_HK_UNIT) { + OsalUSleep(1); + count++; } HDF_LOGI("poll thread exited"); HdfDevListenerThreadFree(thread); -- Gitee