From f3197c64065c4868f0a186e6d55e84d13d267f4e Mon Sep 17 00:00:00 2001 From: chendejin Date: Tue, 24 Dec 2024 12:34:31 +0800 Subject: [PATCH] Select least peer active session --- src/transport/SessionManager.cpp | 4 ++-- src/transport/tests/TestSessionManager.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index 5a895e8054c41b..b90972d5dc133b 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -1297,7 +1297,7 @@ Optional SessionManager::FindSecureSessionForNode(ScopedNodeId pe { #if INET_CONFIG_ENABLE_TCP_ENDPOINT // Set up a TCP transport based session as standby - if ((tcpSession == nullptr || tcpSession->GetLastActivityTime() < session->GetLastActivityTime()) && + if ((tcpSession == nullptr || tcpSession->GetLastPeerActivityTime() < session->GetLastPeerActivityTime()) && session->GetTCPConnection() != nullptr) { tcpSession = session; @@ -1305,7 +1305,7 @@ Optional SessionManager::FindSecureSessionForNode(ScopedNodeId pe #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT } - if ((mrpSession == nullptr) || (mrpSession->GetLastActivityTime() < session->GetLastActivityTime())) + if ((mrpSession == nullptr) || (mrpSession->GetLastPeerActivityTime() < session->GetLastPeerActivityTime())) { mrpSession = session; } diff --git a/src/transport/tests/TestSessionManager.cpp b/src/transport/tests/TestSessionManager.cpp index dfe3ca4fd5c5ff..41a3a1d02ec2a4 100644 --- a/src/transport/tests/TestSessionManager.cpp +++ b/src/transport/tests/TestSessionManager.cpp @@ -998,19 +998,19 @@ TEST_F(TestSessionManager, TestFindSecureSessionForNode) CHIP_ERROR err = sessionManager.InjectCaseSessionWithTestKey(aliceToBobSession, 2, 1, aliceNodeId, bobNodeId, aliceFabricIndex, peer, CryptoContext::SessionRole::kInitiator); EXPECT_EQ(err, CHIP_NO_ERROR); - aliceToBobSession->AsSecureSession()->MarkActive(); + aliceToBobSession->AsSecureSession()->MarkActiveRx(); SessionHolder newAliceToBobSession; err = sessionManager.InjectCaseSessionWithTestKey(newAliceToBobSession, 3, 4, aliceNodeId, bobNodeId, aliceFabricIndex, peer, CryptoContext::SessionRole::kInitiator); EXPECT_EQ(err, CHIP_NO_ERROR); - while (System::SystemClock().GetMonotonicTimestamp() <= aliceToBobSession->AsSecureSession()->GetLastActivityTime()) + while (System::SystemClock().GetMonotonicTimestamp() <= aliceToBobSession->AsSecureSession()->GetLastPeerActivityTime()) { // Wait for the clock to advance so the new session is // more-recently-active. } - newAliceToBobSession->AsSecureSession()->MarkActive(); + newAliceToBobSession->AsSecureSession()->MarkActiveRx(); auto foundSession = sessionManager.FindSecureSessionForNode(ScopedNodeId(bobNodeId, aliceFabricIndex), MakeOptional(SecureSession::Type::kCASE));