diff --git a/core/adapter/syscall/src/hdf_syscall_adapter.c b/core/adapter/syscall/src/hdf_syscall_adapter.c index d389783192f3c666b04d32ab1511409288623237..2759120dc6fdacb63d7613ae8b2bec7ebdb8f693 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 TIMEOUT_US 100000 // 100ms 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,11 +610,17 @@ 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) { + while (thread->status != LISTENER_EXITED && count <= TIMEOUT_US) { OsalUSleep(1); + count++; + } + if (thread->status == LISTENER_EXITED) { + HDF_LOGI("poll thread exited"); + HdfDevListenerThreadFree(thread); + } else { + thread->shouldStop = true; + HDF_LOGE("wait poll thread exit timeout, async exit"); } - HDF_LOGI("poll thread exited"); - HdfDevListenerThreadFree(thread); return; } case LISTENER_STARTED: