Skip to content

Commit

Permalink
Ensure that we shut down open exchanges when controller shuts down.
Browse files Browse the repository at this point in the history
We already handled shutdown of any ongoing PASE bits.

This PR adds two more things:

1) Shutting down any ongoing CASE session establishment exchanges for
   which we are the initiator.  This is done by shutting down all the
   operational device proxies on our mCASESessionManager (since we own
   all of those anyway) and fixing operational device proxy
   shutdown/destruction to actually clean up the CASEClient if we're
   still in the middle of CASE establishment.

2) Expiring the SecureSessions for our fabric, so that any still-open
   operational exchanges for those sessions get closed correctly (with
   a timeout).  This is needed because our client cluster APIs don't
   give us any way to cancel the operation (invoke, read, write, etc)
   and we need to make sure those get cleaned up when we shut down.

Fixes #15760
  • Loading branch information
bzbarsky-apple committed Mar 3, 2022
1 parent 4ab9f60 commit 6b6ffe4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/app/OperationalDeviceProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ CHIP_ERROR OperationalDeviceProxy::ShutdownSubscriptions()
return app::InteractionModelEngine::GetInstance()->ShutdownSubscriptions(mFabricInfo->GetFabricIndex(), GetDeviceId());
}

OperationalDeviceProxy::~OperationalDeviceProxy() {}
OperationalDeviceProxy::~OperationalDeviceProxy() {
if (mCASEClient)
{
// Make sure we don't leak it.
mInitParams.clientPool->Release(mCASEClient);
}
}

} // namespace chip
13 changes: 13 additions & 0 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,19 @@ CHIP_ERROR DeviceController::Shutdown()

mState = State::NotInitialized;

if (mFabricInfo != nullptr) {
// Shut down any ongoing CASE session activity we have.
// https://github.com/project-chip/connectedhomeip/issues/15808 tracks
// the weird use of compressed fabric id as a key here.
mCASESessionManager->ReleaseSessionForFabric(GetCompressedFabricId());

// TODO: The CASE session manager does not shut down existing CASE
// sessions. It just shuts down any ongoing CASE session establishment
// we're in the middle of as initiator. Maybe it should shut down
// existing sessions too?
mSystemState->SessionMgr()->ExpireAllPairingsForFabric(mFabricInfo->GetFabricIndex());
}

mStorageDelegate = nullptr;

if (mFabricInfo != nullptr)
Expand Down

0 comments on commit 6b6ffe4

Please sign in to comment.