From a9c2001bf10b0fc838b8e259c382b62e12c8f81d Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 10 Jul 2025 18:15:11 -0700 Subject: [PATCH] [instance] improve shutdown sequence in `Instance::Finalize()` (#11706) This commit enhances the instance shutdown sequence by explicitly disabling the Border Agent in `Instance::Finalize()`. Additionally, direct calls to the OpenThread C API, such as `otThreadSetEnabled()`, are replaced with their corresponding C++ method calls, like `Get().Stop()`. --- src/core/instance/instance.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/instance/instance.cpp b/src/core/instance/instance.cpp index 133a872da..f9aa03765 100644 --- a/src/core/instance/instance.cpp +++ b/src/core/instance/instance.cpp @@ -430,10 +430,12 @@ void Instance::Finalize(void) mIsInitialized = false; #if OPENTHREAD_MTD || OPENTHREAD_FTD - IgnoreError(otThreadSetEnabled(this, false)); - IgnoreError(otIp6SetEnabled(this, false)); - IgnoreError(otLinkSetEnabled(this, false)); - +#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE + Get().SetEnabled(false); +#endif + Get().Stop(); + Get().Down(); + Get().SetEnabled(false); #if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE Get().DestroyTemporaryKeys(); #endif