From ccede82b2425b909933d0cc768a3e8f1ee327e31 Mon Sep 17 00:00:00 2001 From: libo429 Date: Thu, 29 May 2025 15:18:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=99=E6=80=81=E5=B1=80=E9=83=A8=E5=8F=98?= =?UTF-8?q?=E9=87=8F=20=E5=A4=9A=E7=BA=BF=E7=A8=8B=E9=87=8D=E5=85=A5crash?= =?UTF-8?q?=20=E6=8C=91=E5=8D=955.1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: libo429 --- radar/include/dm_radar_helper.h | 3 +++ radar/src/dm_radar_helper.cpp | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/radar/include/dm_radar_helper.h b/radar/include/dm_radar_helper.h index 1bfb18159..1ab665ba9 100644 --- a/radar/include/dm_radar_helper.h +++ b/radar/include/dm_radar_helper.h @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -245,6 +246,8 @@ public: private: std::string GetAnonyUdid(std::string udid); int32_t GetApiType(); + std::string localCallerName_; + std::mutex lock_; }; extern "C" IDmRadarHelper *CreateDmRadarInstance(); diff --git a/radar/src/dm_radar_helper.cpp b/radar/src/dm_radar_helper.cpp index c62a930cb..7c8f66f80 100644 --- a/radar/src/dm_radar_helper.cpp +++ b/radar/src/dm_radar_helper.cpp @@ -1251,9 +1251,15 @@ void DmRadarHelper::ReportGetLocalDevInfo(std::string hostName, std::string funcName, DmDeviceInfo &info, int32_t errCode, std::string localUdid) { int32_t res = DM_OK; - static std::string localCallerName = ""; - if (localCallerName != hostName) { - localCallerName = hostName; + bool compare = false; + { + std::lock_guard autoLock(lock_); + if (localCallerName_ != hostName) { + compare = true; + localCallerName_ = hostName; + } + } + if (compare) { if (errCode == DM_OK) { res = ReportGetLocalDevInfoResultSucc(hostName, funcName, info, errCode, localUdid); } else { -- Gitee