From 4f8a2a7346cda5c394a9d3ba72cd1b96343d213d Mon Sep 17 00:00:00 2001 From: h60047265 Date: Thu, 9 Jan 2025 15:40:35 +0800 Subject: [PATCH] =?UTF-8?q?=E2=80=9D=E5=87=8F=E5=B0=8F=E9=94=81=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E9=81=BF=E5=85=8D=E6=AD=BB=E9=94=81=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: h60047265 --- .../source/collect/common_event_collect.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/services/samgr/native/source/collect/common_event_collect.cpp b/services/samgr/native/source/collect/common_event_collect.cpp index 03573d82..2d497567 100644 --- a/services/samgr/native/source/collect/common_event_collect.cpp +++ b/services/samgr/native/source/collect/common_event_collect.cpp @@ -385,8 +385,10 @@ void CommonEventCollect::SaveOnDemandConditionExtraData(const EventFwk::CommonEv void CommonEventCollect::RemoveOnDemandReasonExtraData(int64_t extraDataId) { - std::lock_guard autoLock(extraDataLock_); - extraDatas_.erase(extraDataId); + { + std::lock_guard autoLock(extraDataLock_); + extraDatas_.erase(extraDataId); + } HILOGD("CommonEventCollect remove extraData %{public}d", static_cast(extraDataId)); RemoveSaExtraDataId(extraDataId); } @@ -459,13 +461,16 @@ void CommonEventCollect::ClearSaExtraDataId(int32_t saId) int32_t CommonEventCollect::GetSaExtraDataIdList(int32_t saId, std::vector& extraDataidList, const std::string& eventName) { - std::lock_guard autoLock(saExtraDataIdLock_); - if (saExtraDataIdMap_.count(saId) == 0) { - HILOGD("NF exId SA:%{public}d", saId); - return ERR_OK; + std::list temp; + { + std::lock_guard autoLock(saExtraDataIdLock_); + if (saExtraDataIdMap_.count(saId) == 0) { + HILOGD("NF exId SA:%{public}d", saId); + return ERR_OK; + } + HILOGD("get exId SA:%{public}d event:%{public}s", saId, eventName.c_str()); + temp = saExtraDataIdMap_[saId]; } - HILOGD("get exId SA:%{public}d event:%{public}s", saId, eventName.c_str()); - std::list temp = saExtraDataIdMap_[saId]; if (eventName == "") { std::copy(temp.begin(), temp.end(), std::back_inserter(extraDataidList)); return ERR_OK; -- Gitee