diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp index 41058931c2801e..203c375c4f8dc7 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -476,28 +476,6 @@ void MatterOperationalCredentialsPluginServerInitCallback(void) DeviceLayer::PlatformMgrImpl().AddEventHandler(OnPlatformEventHandler); } -namespace { -class FabricCleanupExchangeDelegate : public chip::Messaging::ExchangeDelegate -{ -public: - CHIP_ERROR OnMessageReceived(chip::Messaging::ExchangeContext * ec, const PayloadHeader & payloadHeader, - System::PacketBufferHandle && payload) override - { - return CHIP_NO_ERROR; - } - void OnResponseTimeout(chip::Messaging::ExchangeContext * ec) override {} - void OnExchangeClosing(chip::Messaging::ExchangeContext * ec) override - { - SessionManager * sessionManager = ec->GetExchangeMgr()->GetSessionManager(); - FabricIndex currentFabricIndex = ec->GetSessionHandle()->GetFabricIndex(); - CleanupSessionsForFabric(*sessionManager, currentFabricIndex); - } -}; - -FabricCleanupExchangeDelegate gFabricCleanupExchangeDelegate; - -} // namespace - bool emberAfOperationalCredentialsClusterRemoveFabricCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::RemoveFabric::DecodableType & commandData) @@ -543,15 +521,7 @@ bool emberAfOperationalCredentialsClusterRemoveFabricCallback(app::CommandHandle FabricIndex currentFabricIndex = commandObj->GetAccessingFabricIndex(); if (currentFabricIndex == fabricBeingRemoved) { - // 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); + ec->AbortAllOtherCommunicationOnFabric(); } else {