From 8fc4ea491fca612f6d5d1f0f69dab4bad00bf649 Mon Sep 17 00:00:00 2001 From: zhuhan Date: Mon, 23 Oct 2023 21:25:35 +0800 Subject: [PATCH] add lock Signed-off-by: zhuhan Change-Id: I9e1d38788e77e4260e8f3bef546ac4580bf8cc74 --- services/abilitymgr/include/pending_want_key.h | 2 ++ services/abilitymgr/src/pending_want_key.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/services/abilitymgr/include/pending_want_key.h b/services/abilitymgr/include/pending_want_key.h index 94f13ed51f..1d9dcc61c6 100644 --- a/services/abilitymgr/include/pending_want_key.h +++ b/services/abilitymgr/include/pending_want_key.h @@ -16,6 +16,7 @@ #ifndef OHOS_ABILITY_RUNTIME_PENDING_WANT_KEY_H #define OHOS_ABILITY_RUNTIME_PENDING_WANT_KEY_H +#include #include #include @@ -64,6 +65,7 @@ private: int32_t flags_ = {}; int32_t code_ = {}; int32_t userId_ = {}; + std::mutex wantsInfosMutex_; }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/pending_want_key.cpp b/services/abilitymgr/src/pending_want_key.cpp index 7a69d53bd6..132b0a9a65 100644 --- a/services/abilitymgr/src/pending_want_key.cpp +++ b/services/abilitymgr/src/pending_want_key.cpp @@ -50,6 +50,7 @@ void PendingWantKey::SetRequestResolvedType(const std::string &requestResolvedTy void PendingWantKey::SetAllWantsInfos(const std::vector &allWantsInfos) { + std::lock_guard lock(wantsInfosMutex_); allWantsInfos_ = allWantsInfos; } @@ -105,6 +106,7 @@ std::string PendingWantKey::GetRequestResolvedType() std::vector PendingWantKey::GetAllWantsInfos() { + std::lock_guard lock(wantsInfosMutex_); return allWantsInfos_; }