From 6b52515cadf3a8c40ddb27e74c2b66e751671828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=81=E7=AB=9E=E8=8E=9C?= Date: Sat, 6 Sep 2025 17:16:38 +0800 Subject: [PATCH 1/2] sync yellow code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 宁竞莜 --- .../src/channel_manager/channel_manager.cpp | 2 ++ .../src/channel_manager/system_notifier.cpp | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/services/distributedfiledaemon/src/channel_manager/channel_manager.cpp b/services/distributedfiledaemon/src/channel_manager/channel_manager.cpp index 854ad20fd..46fe0ee00 100644 --- a/services/distributedfiledaemon/src/channel_manager/channel_manager.cpp +++ b/services/distributedfiledaemon/src/channel_manager/channel_manager.cpp @@ -115,6 +115,7 @@ int32_t ChannelManager::Init() int32_t ret = Listen(socketServerId, g_low_qosInfo, g_lowQosTvParamIndex, &channelManagerListener); if (ret != ERR_OK) { LOGE("service listen failed, ret: %{public}d", ret); + Shutdown(socketServerId); return ERR_LISTEN_SOCKET_FAILED; } @@ -263,6 +264,7 @@ int32_t ChannelManager::CreateClientChannel(const std::string &networkId) } if (!SoftBusPermissionCheck::SetAccessInfoToSocket(socketId)) { LOGE("Fill and set accessInfo failed"); + Shutdown(socketId); return ERR_BAD_VALUE; } diff --git a/services/distributedfiledaemon/src/channel_manager/system_notifier.cpp b/services/distributedfiledaemon/src/channel_manager/system_notifier.cpp index a62247228..8002c7291 100644 --- a/services/distributedfiledaemon/src/channel_manager/system_notifier.cpp +++ b/services/distributedfiledaemon/src/channel_manager/system_notifier.cpp @@ -249,7 +249,6 @@ void SystemNotifier::UpdateResourceMapByLanguage() template std::string SystemNotifier::GetKeyValue(const std::string &key, Args &&...args) { - std::lock_guard lock(g_resourceMapMutex); auto it = g_resourceMap.find(key); if (it == g_resourceMap.end()) { return ""; -- Gitee From b008126cd01745ab16df895b0ed8d9ce657a57a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=81=E7=AB=9E=E8=8E=9C?= Date: Sat, 6 Sep 2025 17:43:33 +0800 Subject: [PATCH 2/2] sync yellow code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 宁竞莜 --- .../include/channel_manager/system_notifier.h | 2 +- .../distributedfiledaemon/include/network/session_pool.h | 2 +- .../src/channel_manager/system_notifier.cpp | 2 +- services/distributedfiledaemon/src/ipc/daemon_stub.cpp | 5 +++-- .../src/network/network_agent_template.cpp | 9 ++++++--- .../distributedfiledaemon/src/network/session_pool.cpp | 5 ++++- .../unittest/channel_manager/control_cmd_parser_test.cpp | 2 +- 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/services/distributedfiledaemon/include/channel_manager/system_notifier.h b/services/distributedfiledaemon/include/channel_manager/system_notifier.h index f704e319f..75e88e42c 100644 --- a/services/distributedfiledaemon/include/channel_manager/system_notifier.h +++ b/services/distributedfiledaemon/include/channel_manager/system_notifier.h @@ -40,7 +40,7 @@ public: int32_t CreateLocalLiveView(const std::string &networkId); int32_t CreateNotification(const std::string &networkId); - int32_t DestroyNotifyByNetworkId(const std::string &networkId); + int32_t DestroyNotifyByNetworkId(const std::string &networkId, bool needNotifyRemote = true); int32_t DestroyNotifyByNotificationId(int32_t notifyId); void ClearAllConnect(); int32_t GetNotificationMapSize(); diff --git a/services/distributedfiledaemon/include/network/session_pool.h b/services/distributedfiledaemon/include/network/session_pool.h index 852107276..72b422a2a 100644 --- a/services/distributedfiledaemon/include/network/session_pool.h +++ b/services/distributedfiledaemon/include/network/session_pool.h @@ -36,7 +36,7 @@ public: void ReleaseSession(const int32_t fd); void ReleaseSession(const std::string &cid, bool isReleaseAll); void ReleaseAllSession(); - bool CheckIfGetSession(const int32_t fd); + bool CheckIfGetSession(const int32_t fd, bool &isServer); void SinkOffline(const std::string &cid); bool FindSocketId(int32_t socketId); private: diff --git a/services/distributedfiledaemon/src/channel_manager/system_notifier.cpp b/services/distributedfiledaemon/src/channel_manager/system_notifier.cpp index 8002c7291..b08661565 100644 --- a/services/distributedfiledaemon/src/channel_manager/system_notifier.cpp +++ b/services/distributedfiledaemon/src/channel_manager/system_notifier.cpp @@ -395,7 +395,7 @@ int32_t SystemNotifier::DestroyNotifyByNotificationId(int32_t notificationId) return ret; } -int32_t SystemNotifier::DestroyNotifyByNetworkId(const std::string &networkId) +int32_t SystemNotifier::DestroyNotifyByNetworkId(const std::string &networkId, bool needNotifyRemote) { LOGI("DestroyNotifyByNetworkId for networkId: %{public}.6s", networkId.c_str()); int32_t notificationId = 0; diff --git a/services/distributedfiledaemon/src/ipc/daemon_stub.cpp b/services/distributedfiledaemon/src/ipc/daemon_stub.cpp index 2fa662dbf..135dd40ca 100644 --- a/services/distributedfiledaemon/src/ipc/daemon_stub.cpp +++ b/services/distributedfiledaemon/src/ipc/daemon_stub.cpp @@ -186,9 +186,10 @@ int32_t DaemonStub::HandleOpenP2PConnectionEx(MessageParcel &data, MessageParcel return E_IPC_READ_FAILED; } auto remote = data.ReadRemoteObject(); - LOGW("is FileManager ? result is %{public}d", remote == nullptr); - auto remoteReverseObj = iface_cast(remote); + if (remoteReverseObj == nullptr) { + LOGW("nullptr pass, is FileManager situation!"); + } int32_t res = OpenP2PConnectionEx(networkId, remoteReverseObj); reply.WriteInt32(res); LOGI("DaemonStub::End OpenP2PConnection, res = %{public}d.", res); diff --git a/services/distributedfiledaemon/src/network/network_agent_template.cpp b/services/distributedfiledaemon/src/network/network_agent_template.cpp index 484676166..89b463dbe 100644 --- a/services/distributedfiledaemon/src/network/network_agent_template.cpp +++ b/services/distributedfiledaemon/src/network/network_agent_template.cpp @@ -181,15 +181,18 @@ void NetworkAgentTemplate::GetSessionProcessInner(NotifyParam param) string cidStr(param.remoteCid, CID_MAX_LEN); int fd = param.fd; LOGI("NOTIFY_GET_SESSION, old fd %{public}d, remote cid %{public}s", fd, Utils::GetAnonyString(cidStr).c_str()); - bool ifGetSession = sessionPool_.CheckIfGetSession(fd); + bool isServer = false; + bool ifGetSession = sessionPool_.CheckIfGetSession(fd, isServer); sessionPool_.ReleaseSession(fd); if (ifGetSession && ConnectCount::GetInstance()->CheckCount(cidStr)) { // for client GetSession(cidStr); } else { - // for server + // for server and client active close sessionPool_.SinkOffline(cidStr); - SystemNotifier::GetInstance().DestroyNotifyByNetworkId(cidStr); + } + if (isServer) { + SystemNotifier::GetInstance().DestroyNotifyByNetworkId(cidStr, false); } } diff --git a/services/distributedfiledaemon/src/network/session_pool.cpp b/services/distributedfiledaemon/src/network/session_pool.cpp index 76e6e715f..08b41defe 100644 --- a/services/distributedfiledaemon/src/network/session_pool.cpp +++ b/services/distributedfiledaemon/src/network/session_pool.cpp @@ -48,7 +48,7 @@ void SessionPool::ReleaseSession(const int32_t fd) } } -bool SessionPool::CheckIfGetSession(const int32_t fd) +bool SessionPool::CheckIfGetSession(const int32_t fd, bool &isServer) { lock_guard lock(sessionPoolLock_); std::shared_ptr session = nullptr; @@ -59,8 +59,11 @@ bool SessionPool::CheckIfGetSession(const int32_t fd) } } if (session == nullptr) { + // client disconnect, server allconnect disconnect + isServer = false; return false; } + isServer = session->IsFromServer(); return !session->IsFromServer(); } diff --git a/services/distributedfiledaemon/test/unittest/channel_manager/control_cmd_parser_test.cpp b/services/distributedfiledaemon/test/unittest/channel_manager/control_cmd_parser_test.cpp index 685c90b5e..580651b9f 100644 --- a/services/distributedfiledaemon/test/unittest/channel_manager/control_cmd_parser_test.cpp +++ b/services/distributedfiledaemon/test/unittest/channel_manager/control_cmd_parser_test.cpp @@ -38,7 +38,7 @@ int32_t SystemNotifier::CreateLocalLiveView(const std::string &networkId) return g_publishNotification; } -int32_t SystemNotifier::DestroyNotifyByNetworkId(const std::string &networkId) +int32_t SystemNotifier::DestroyNotifyByNetworkId(const std::string &networkId, bool needNotifyRemonte) { return g_cancelNotification; } -- Gitee