diff --git a/services/implementation/include/device_manager_service_impl.h b/services/implementation/include/device_manager_service_impl.h index 9efda6ff9b6370b71ba5bf01aec3133ab07da5dc..75b46dbad39f0831ef09014f33ba392c4033e94b 100644 --- a/services/implementation/include/device_manager_service_impl.h +++ b/services/implementation/include/device_manager_service_impl.h @@ -302,7 +302,8 @@ private: void DeleteSessionKey(int32_t userId, const DistributedDeviceProfile::AccessControlProfile &profile); private: std::shared_ptr authMgr_; // Old protocol only - + bool isNeedJoinLnn_ = true; + std::mutex isNeedJoinLnnMtx_; std::shared_ptr hiChainConnector_; std::shared_ptr hiChainAuthConnector_; std::shared_ptr deviceStateMgr_; diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index 75dfdec64fd6d69d66349e33d53d2b93ba2d74d8..25b29563fecfc92374a6bcdde071c82ff8260f53 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -68,6 +68,9 @@ constexpr const char* DM_TAG_EXTRA_INFO = "extraInfo"; constexpr const char* FILED_AUTHORIZED_APP_LIST = "authorizedAppList"; constexpr const char* CHANGE_PINTYPE = "1"; constexpr const char* BIND_CALLER_USERID = "bindCallerUserId"; +const char* IS_NEED_JOIN_LNN = "IsNeedJoinLnn"; +constexpr const char* NEED_JOIN_LNN = "0"; +constexpr const char* NO_NEED_JOIN_LNN = "1"; // currently, we just support one bind session in one device at same time constexpr size_t MAX_NEW_PROC_SESSION_COUNT_TEMP = 1; const int32_t USLEEP_TIME_US_500000 = 500000; // 500ms @@ -325,7 +328,13 @@ void DeviceManagerServiceImpl::CleanSessionMap(int sessionId, std::shared_ptrlogicalSessionCnt_.fetch_sub(1); if (session->logicalSessionCnt_.load(std::memory_order_relaxed) == 0) { - usleep(USLEEP_TIME_US_500000); + { + std::lock_guard lock(isNeedJoinLnnMtx_); + if (isNeedJoinLnn_) { + usleep(USLEEP_TIME_US_500000); + } + isNeedJoinLnn_ = true; + } CHECK_NULL_VOID(softbusConnector_); softbusConnector_->GetSoftbusSession()->CloseAuthSession(sessionId); std::lock_guard lock(mapMutex_); @@ -1668,7 +1677,17 @@ int32_t DeviceManagerServiceImpl::ParseConnectAddr(const PeerTargetId &targetId, if (bindParam.count(PARAM_KEY_CONN_ADDR_TYPE) != 0) { addrType = bindParam.at(PARAM_KEY_CONN_ADDR_TYPE); } - + std::string isNeedJoinLnnStr; + if (bindParam.find(IS_NEED_JOIN_LNN) != bindParam.end()) { + isNeedJoinLnnStr = bindParam.at(IS_NEED_JOIN_LNN); + } + LOGI("isNeedJoinLnnStr: %{public}s.", isNeedJoinLnnStr.c_str()); + { + std::lock_guard lock(isNeedJoinLnnMtx_); + if (isNeedJoinLnnStr == NEED_JOIN_LNN || isNeedJoinLnnStr == NO_NEED_JOIN_LNN) { + isNeedJoinLnn_ = std::atoi(isNeedJoinLnnStr.c_str()); + } + } std::shared_ptr deviceInfo = std::make_shared(); int32_t index = 0; int32_t ret = GetDeviceInfo(targetId, addrType, deviceId, deviceInfo, index);