From a2c6e71a390e0612e90b3d0c21adb2f4aafcb02d Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Wed, 26 Feb 2025 14:13:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E8=AE=BE=E5=A4=87=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E4=B8=8B=E7=BA=BF=E6=97=B6=E5=BA=8F=E9=9A=BE=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=EF=BC=8C=E4=BD=8E=E6=A6=82=E7=8E=87=E5=90=8C=E6=97=B6=E9=87=8A?= =?UTF-8?q?=E6=94=BE=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- .../include/distributed_hardware_manager_factory.h | 4 +++- .../src/distributed_hardware_manager_factory.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h b/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h index 91c8df2c..f8215111 100644 --- a/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h +++ b/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -50,6 +50,8 @@ private: private: std::atomic isInit_ = false; std::atomic flagUnInit_ = false; + std::atomic releaseStatus_ = false; + std::mutex releaseProcessMutex_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index e3ba5839..1b6a7411 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -86,6 +86,7 @@ bool DistributedHardwareManagerFactory::Init() return false; } isInit_.store(true); + releaseStatus_.store(false); DHLOGI("success"); return true; } @@ -93,6 +94,12 @@ bool DistributedHardwareManagerFactory::Init() void DistributedHardwareManagerFactory::UnInit() { DHLOGI("start"); + std::lock_guard lock(releaseProcessMutex_); + if (releaseStatus_.load()) { + DHLOGE("Releasing resources is complete, not need to be released again."); + return; + } + releaseStatus_.store(true); DHTraceStart(COMPONENT_UNLOAD_START); HiSysEventWriteMsg(DHFWK_EXIT_BEGIN, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa exit begin."); -- Gitee