diff --git a/av_transport/common/src/softbus_channel_adapter.cpp b/av_transport/common/src/softbus_channel_adapter.cpp index 9818f36984a04097dfce77c337aa9aa320838cf4..a09c0a214a7d7f8331b25b2e25aa6b57c8a3f128 100644 --- a/av_transport/common/src/softbus_channel_adapter.cpp +++ b/av_transport/common/src/softbus_channel_adapter.cpp @@ -321,12 +321,12 @@ int32_t SoftbusChannelAdapter::OnSoftbusChannelOpened(int32_t sessionId, int32_t AVTransEvent event = {type, sessName, peerDevId}; { - std::lock_guard lock(listenerMtx_); - for (auto it = listenerMap_.begin(); it != listenerMap_.end(); it++) { - if (((it->first).find(sessName) != std::string::npos) && (it->second != nullptr)) { - std::thread(&SoftbusChannelAdapter::SendChannelEvent, this, it->second, event).detach(); - { - std::lock_guard lock(idMapMutex_); + std::lock_guard lock(idMapMutex_); + { + std::lock_guard lock(listenerMtx_); + for (auto it = listenerMap_.begin(); it != listenerMap_.end(); it++) { + if (((it->first).find(sessName) != std::string::npos) && (it->second != nullptr)) { + std::thread(&SoftbusChannelAdapter::SendChannelEvent, this, it->second, event).detach(); devId2SessIdMap_.erase(it->first); devId2SessIdMap_.insert(std::make_pair(it->first, sessionId)); }