Skip to content

Commit 9417fbb

Browse files
authored
Select least peer active session (#36984)
1 parent 62b2437 commit 9417fbb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/transport/SessionManager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,9 @@ Optional<SessionHandle> SessionManager::FindSecureSessionForNode(ScopedNodeId pe
10571057
(!type.HasValue() || type.Value() == session->GetSecureSessionType()))
10581058
{
10591059
//
1060-
// Select the active session with the most recent activity to return back to the caller.
1060+
// Select the active session with the most recent activity of peer to return back to the caller.
10611061
//
1062-
if ((found == nullptr) || (found->GetLastActivityTime() < session->GetLastActivityTime()))
1062+
if ((found == nullptr) || (found->GetLastPeerActivityTime() < session->GetLastPeerActivityTime()))
10631063
{
10641064
found = session;
10651065
}

src/transport/tests/TestSessionManager.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1029,19 +1029,19 @@ static void TestFindSecureSessionForNode(nlTestSuite * inSuite, void * inContext
10291029
CHIP_ERROR err = sessionManager.InjectCaseSessionWithTestKey(aliceToBobSession, 2, 1, aliceNodeId, bobNodeId, aliceFabricIndex,
10301030
peer, CryptoContext::SessionRole::kInitiator);
10311031
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
1032-
aliceToBobSession->AsSecureSession()->MarkActive();
1032+
aliceToBobSession->AsSecureSession()->MarkActiveRx();
10331033

10341034
SessionHolder newAliceToBobSession;
10351035
err = sessionManager.InjectCaseSessionWithTestKey(newAliceToBobSession, 3, 4, aliceNodeId, bobNodeId, aliceFabricIndex, peer,
10361036
CryptoContext::SessionRole::kInitiator);
10371037
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
10381038

1039-
while (System::SystemClock().GetMonotonicTimestamp() <= aliceToBobSession->AsSecureSession()->GetLastActivityTime())
1039+
while (System::SystemClock().GetMonotonicTimestamp() <= aliceToBobSession->AsSecureSession()->GetLastPeerActivityTime())
10401040
{
10411041
// Wait for the clock to advance so the new session is
10421042
// more-recently-active.
10431043
}
1044-
newAliceToBobSession->AsSecureSession()->MarkActive();
1044+
newAliceToBobSession->AsSecureSession()->MarkActiveRx();
10451045

10461046
auto foundSession = sessionManager.FindSecureSessionForNode(ScopedNodeId(bobNodeId, aliceFabricIndex),
10471047
MakeOptional(SecureSession::Type::kCASE));

0 commit comments

Comments
 (0)