From 1500264e3fa9430ec43d84281bf1cbdedc320121 Mon Sep 17 00:00:00 2001 From: Dohyun Pyun Date: Sat, 22 Jul 2023 00:20:17 +0900 Subject: [PATCH] Fix the deadlock issue during shutdown the system layer (#28094) When the app calls PlatformManager's Shutdown API twice, the function tries to join the abnormal main loop's thread. Adds the prevent function to avoid this deadlock issue. --- src/platform/Tizen/PlatformManagerImpl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/platform/Tizen/PlatformManagerImpl.cpp b/src/platform/Tizen/PlatformManagerImpl.cpp index 9f55f3b824f3de..27174a6c4c74ee 100644 --- a/src/platform/Tizen/PlatformManagerImpl.cpp +++ b/src/platform/Tizen/PlatformManagerImpl.cpp @@ -129,11 +129,19 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() void PlatformManagerImpl::_Shutdown() { + if (mGLibMainLoop == nullptr) + { + ChipLogError(DeviceLayer, "System Layer is already shutdown."); + return; + } + Internal::GenericPlatformManagerImpl_POSIX::_Shutdown(); g_main_loop_quit(mGLibMainLoop); g_main_loop_unref(mGLibMainLoop); g_thread_join(mGLibMainLoopThread); + + mGLibMainLoop = nullptr; } CHIP_ERROR PlatformManagerImpl::_GLibMatterContextInvokeSync(CHIP_ERROR (*func)(void *), void * userData)