Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[op-creds] Fix RemoveFabric command #13869

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,14 @@ bool emberAfOperationalCredentialsClusterRemoveFabricCallback(app::CommandHandle
FabricIndex currentFabricIndex = commandObj->GetAccessingFabricIndex();
if (currentFabricIndex == fabricBeingRemoved)
{
// If the current fabric is being removed, expiring all the secure sessions causes crashes as
// the message sent by emberAfSendImmediateDefaultResponse() is still in the queue. Also, RMP
// retries to send the message and runs into issues.
// We are hijacking the exchange delegate here (as no more messages should be received on this exchange),
// and wait for it to close, before expiring the secure sessions for the fabric.
// If the current fabric is being removed, don't expire the secure sessions immediately as they are
// still needed to send a pending message generated by emberAfSendImmediateDefaultResponse().
// Hijack the exchange delegate here (as no more messages should be received on this exchange),
// and wait for it to close, before expiring the secure sessions for the fabric. Also, suppress MRP
// usage since the MRP engine still holds an exchange even after it's closed, and the engine references
// the associated session object.
// TODO: https://github.com/project-chip/connectedhomeip/issues/9642
ec->SetAutoRequestAck(false);
ec->SetDelegate(&gFabricCleanupExchangeDelegate);
}
else
Expand Down
7 changes: 7 additions & 0 deletions src/messaging/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@ bool ExchangeContext::MatchExchange(const SessionHandle & session, const PacketH

void ExchangeContext::OnSessionReleased()
{
if (mFlags.Has(Flags::kFlagClosed))
{
// Exchange is already being closed. It may occur when closing an exchange after sending
// RemoveFabric response which triggers removal of all sessions for the given fabric.
return;
}

ExchangeHandle ref(*this);

if (IsResponseExpected())
Expand Down