diff --git a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp index a0b47b0a66a9339aa7a891bc9815c5b86a5b7350..a5d949c035eb7800464b0f3e4b6f963dc7a26c94 100644 --- a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp +++ b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp @@ -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 @@ -1010,7 +1010,7 @@ void DistributedInputSinkManager::CleanExceptionalInfo(const SrcScreenInfo &srcS DHLOGI("CleanExceptionalInfo start!"); std::string uuid = srcScreenInfo.uuid; int32_t sessionId = srcScreenInfo.sessionId; - auto sinkInfos = DInputContext::GetInstance().GetAllSinkScreenInfo(); + std::unordered_map sinkInfos = DInputContext::GetInstance().GetAllSinkScreenInfo(); for (const auto &[id, sinkInfo] : sinkInfos) { auto srcInfo = sinkInfo.srcScreenInfo; diff --git a/utils/src/dinput_context.cpp b/utils/src/dinput_context.cpp index b7226c63ad37c4a03c180bd9a56104c1eea12691..d1e4d7bc892216bc64ff54b44c5062cc012358be 100644 --- a/utils/src/dinput_context.cpp +++ b/utils/src/dinput_context.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -27,8 +27,15 @@ IMPLEMENT_SINGLE_INSTANCE(DInputContext); DInputContext::~DInputContext() { - sinkScreenInfoMap_.clear(); - srcScreenInfoMap_.clear(); + { + std::lock_guard lock(sinkMapMutex_); + sinkScreenInfoMap_.clear(); + } + + { + std::lock_guard lock(srcMapMutex_); + srcScreenInfoMap_.clear(); + } } std::string DInputContext::GetScreenInfoKey(const std::string &devId, const uint64_t sourceWinId)