diff --git a/src/messaging/ExchangeMgr.cpp b/src/messaging/ExchangeMgr.cpp index 210238c29905a1..88cbf36a1e49f8 100644 --- a/src/messaging/ExchangeMgr.cpp +++ b/src/messaging/ExchangeMgr.cpp @@ -43,6 +43,10 @@ #include #include +#if CONFIG_DEVICE_LAYER +#include +#endif + using namespace chip::Encoding; using namespace chip::Inet; using namespace chip::System; @@ -94,6 +98,10 @@ CHIP_ERROR ExchangeManager::Init(SecureSessionMgr * sessionMgr) CHIP_ERROR ExchangeManager::Shutdown() { +// TODO(#6931): Lock guard is a temporary solution. Proper solution should be post chip shutdown function into chip thread +#if CONFIG_DEVICE_LAYER + DeviceLayer::PlatformMgr().LockChipStack(); +#endif mReliableMessageMgr.Shutdown(); mContextPool.ForEachActiveObject([](auto * ec) { @@ -109,6 +117,9 @@ CHIP_ERROR ExchangeManager::Shutdown() } mState = State::kState_NotInitialized; +#if CONFIG_DEVICE_LAYER + DeviceLayer::PlatformMgr().UnlockChipStack(); +#endif return CHIP_NO_ERROR; }