From fdfda02b1b4d312a0b0bd9dfc5785ad3541f2073 Mon Sep 17 00:00:00 2001 From: hejiaogirl Date: Mon, 14 Jul 2025 09:35:13 +0800 Subject: [PATCH] fix : add xcollie for finite state Signed-off-by: hejiaogirl Change-Id: I682bd519a03cc4189b7c3f5866f706b97819f847 --- .../napi/user_auth/src/user_auth_callback_v10.cpp | 1 + services/base/src/thread_handler_impl.cpp | 11 ++++++++++- .../base/src/thread_handler_singleton_impl.cpp | 15 +++++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/frameworks/js/napi/user_auth/src/user_auth_callback_v10.cpp b/frameworks/js/napi/user_auth/src/user_auth_callback_v10.cpp index eeef9dc90..8a66a823d 100644 --- a/frameworks/js/napi/user_auth/src/user_auth_callback_v10.cpp +++ b/frameworks/js/napi/user_auth/src/user_auth_callback_v10.cpp @@ -219,6 +219,7 @@ void UserAuthCallbackV10::OnAcquireInfo(int32_t module, uint32_t acquireInfo, authTipInfoCallbackHolder->tipCode); if (ret != napi_ok) { IAM_LOGE("DoTipInfoCallBack ret = %{public}d", ret); + napi_close_handle_scope(authTipInfoCallbackHolder->env, scope); return; } napi_close_handle_scope(authTipInfoCallbackHolder->env, scope); diff --git a/services/base/src/thread_handler_impl.cpp b/services/base/src/thread_handler_impl.cpp index c9a7d8d2d..0de409d88 100644 --- a/services/base/src/thread_handler_impl.cpp +++ b/services/base/src/thread_handler_impl.cpp @@ -20,9 +20,11 @@ #include #include "nocopyable.h" -#include "thread_handler_manager.h" +#include "iam_ptr.h" #include "iam_logger.h" +#include "thread_handler_manager.h" +#include "xcollie_helper.h" #define LOG_TAG "USER_AUTH_SA" @@ -30,6 +32,7 @@ namespace OHOS { namespace UserIam { namespace UserAuth { using namespace OHOS; +using namespace OHOS::UserIam::Common; ThreadHandlerImpl::ThreadHandlerImpl(std::string name, bool canSuspend) : pool_(name), canSuspend_(canSuspend) { pool_.Start(1); @@ -48,6 +51,12 @@ void ThreadHandlerImpl::PostTask(const Task &task) return; } pool_.AddTask(task); + + constexpr uint32_t TASK_BLOCK_MONITOR_TIMEOUT = 20; + auto taskBlockMonitor = MakeShared("taskBlockMonitor", TASK_BLOCK_MONITOR_TIMEOUT); + pool_.AddTask([taskBlockMonitor] { + (void)taskBlockMonitor; + }); } void ThreadHandlerImpl::EnsureTask(const Task &task) diff --git a/services/base/src/thread_handler_singleton_impl.cpp b/services/base/src/thread_handler_singleton_impl.cpp index c89505de5..406c91c5d 100644 --- a/services/base/src/thread_handler_singleton_impl.cpp +++ b/services/base/src/thread_handler_singleton_impl.cpp @@ -20,10 +20,12 @@ #include #include "nocopyable.h" -#include "relative_timer.h" -#include "thread_handler_manager.h" +#include "iam_ptr.h" #include "iam_logger.h" +#include "relative_timer.h" +#include "thread_handler_manager.h" +#include "xcollie_helper.h" #define LOG_TAG "USER_AUTH_SA" @@ -31,9 +33,18 @@ namespace OHOS { namespace UserIam { namespace UserAuth { using namespace OHOS; +using namespace OHOS::UserIam::Common; void ThreadHandlerSingletonImpl::PostTask(const Task &task) { RelativeTimer::GetInstance().Register(task, 0); + + constexpr uint32_t TASK_BLOCK_MONITOR_TIMEOUT = 20; + auto taskBlockMonitor = MakeShared("taskBlockMonitor", TASK_BLOCK_MONITOR_TIMEOUT); + RelativeTimer::GetInstance().Register( + [taskBlockMonitor] { + (void)taskBlockMonitor; + }, + 0); } void ThreadHandlerSingletonImpl::EnsureTask(const Task &task) -- Gitee