From 8d413621542c2913e7be3b938c303fcca38f963f Mon Sep 17 00:00:00 2001 From: yunhanw Date: Wed, 10 Aug 2022 19:23:10 -0700 Subject: [PATCH] address comments --- src/app/InteractionModelEngine.cpp | 7 ++++--- src/app/InteractionModelEngine.h | 1 + src/app/ReadClient.cpp | 2 +- .../operational-credentials-server.cpp | 1 - src/lib/core/CHIPError.cpp | 3 +++ src/lib/core/CHIPError.h | 8 ++++++++ 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 86439c683e045b..bc1d5d159cdee7 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -77,9 +77,9 @@ void InteractionModelEngine::Shutdown() // while (handlerIter) { - CommandHandlerInterface * pNext = handlerIter->GetNext(); + CommandHandlerInterface * nextHandler = handlerIter->GetNext(); handlerIter->SetNext(nullptr); - handlerIter = pNext; + handlerIter = nextHandler; } mCommandHandlerList = nullptr; @@ -1452,8 +1452,9 @@ void InteractionModelEngine::OnFabricRemoved(const FabricTable & fabricTable, Fa if (readClient->GetFabricIndex() == fabricIndex) { ChipLogProgress(InteractionModel, "Fabric removed, deleting obsolete read client with FabricIndex: %u", fabricIndex); - readClient->Close(CHIP_NO_ERROR, false); RemoveReadClient(readClient); + readClient->mpImEngine = nullptr; + readClient->Close(CHIP_ERROR_IM_FABRIC_DELETED, false); } } diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index 8da9281f326ac2..72be20da0f7326 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -290,6 +290,7 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, */ uint16_t GetMinGuaranteedSubscriptionsPerFabric() const; + // virtual method from FabricTable::Delegate void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) override; #if CONFIG_BUILD_FOR_HOST_UNIT_TEST diff --git a/src/app/ReadClient.cpp b/src/app/ReadClient.cpp index bdce6443171feb..19e1ced153334c 100644 --- a/src/app/ReadClient.cpp +++ b/src/app/ReadClient.cpp @@ -86,7 +86,7 @@ ReadClient::~ReadClient() // This won't be the case if the engine shut down before this destructor was called (in which case, mpImEngine // will point to null) // - if (mpImEngine && mpImEngine->InActiveReadClientList(this)) + if (mpImEngine) { mpImEngine->RemoveReadClient(this); } 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 ca8aedcbcdfc37..a132b905553bb1 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -385,7 +385,6 @@ class OpCredsFabricTableDelegate : public chip::FabricTable::Delegate // Gets called when a fabric is added/updated, but not necessarily committed to storage void OnFabricUpdated(const FabricTable & fabricTable, FabricIndex fabricIndex) override { - ChipLogProgress(InteractionModel, "OnFabricUpdated debugging from opertonal-credential!!!!!!!"); NotifyFabricTableChanged(); } diff --git a/src/lib/core/CHIPError.cpp b/src/lib/core/CHIPError.cpp index c66f2d3cd51321..ebbd7bac93ea57 100644 --- a/src/lib/core/CHIPError.cpp +++ b/src/lib/core/CHIPError.cpp @@ -731,6 +731,9 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err) case CHIP_ERROR_MISSING_URI_SEPARATOR.AsInteger(): desc = "The URI separator is missing"; break; + case CHIP_ERROR_IM_FABRIC_DELETED.AsInteger(): + desc = "The fabric is deleted, and the corresponding IM resources are released"; + break; } #endif // !CHIP_CONFIG_SHORT_ERROR_STR diff --git a/src/lib/core/CHIPError.h b/src/lib/core/CHIPError.h index be898418b86b8e..271d02c5c4ad27 100644 --- a/src/lib/core/CHIPError.h +++ b/src/lib/core/CHIPError.h @@ -2428,6 +2428,14 @@ using CHIP_ERROR = ::chip::ChipError; */ #define CHIP_ERROR_MISSING_URI_SEPARATOR CHIP_CORE_ERROR(0xe0) +/** + * @def CHIP_ERROR_IM_FABRIC_DELETED + * + * @brief + * The fabric is deleted, and the corresponding IM resources are released + */ +#define CHIP_ERROR_IM_FABRIC_DELETED CHIP_CORE_ERROR(0xe1) + // clang-format on // !!!!! IMPORTANT !!!!! If you add new CHIP errors, please update the translation