File tree 1 file changed +20
-1
lines changed
src/darwin/Framework/CHIP
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -4786,9 +4786,28 @@ - (void)_deviceMayBeReachable
4786
4786
[self _resetSubscription];
4787
4787
}
4788
4788
4789
+ auto peerScopeId = commissioner->GetPeerScopedId(self->_nodeID.unsignedLongLongValue);
4789
4790
auto caseSessionMgr = commissioner->CASESessionMgr();
4790
4791
VerifyOrDie(caseSessionMgr != nullptr);
4791
- caseSessionMgr->ReleaseSession(commissioner->GetPeerScopedId(self->_nodeID.unsignedLongLongValue));
4792
+ caseSessionMgr->ReleaseSession(peerScopeId);
4793
+
4794
+ // TODO: make this configurable - for now use 1.5 second
4795
+ #define MTRDEVICE_ACTIVE_SESSION_THRESHOLD_MILLISECONDS (15000)
4796
+ auto sessionMgr = commissioner->SessionMgr();
4797
+ VerifyOrDie(sessionMgr != nullptr);
4798
+ sessionMgr->ForEachMatchingSession(peerScopeId, [](auto * session) {
4799
+ auto secureSession = session->AsSecureSession();
4800
+ if (!secureSession) {
4801
+ return;
4802
+ }
4803
+
4804
+ auto threshold = System::Clock::Timeout(MTRDEVICE_ACTIVE_SESSION_THRESHOLD_MILLISECONDS);
4805
+ if ((System::SystemClock().GetMonotonicTimestamp() - session->GetLastPeerActivityTime()) < threshold) {
4806
+ return;
4807
+ }
4808
+
4809
+ session->MarkAsDefunct();
4810
+ });
4792
4811
4793
4812
std::lock_guard lock(self->_lock);
4794
4813
// Use _ensureSubscriptionForExistingDelegates so that the subscriptions
You can’t perform that action at this time.
0 commit comments