Skip to content

Commit

Permalink
Fix the deadlock issue during shutdown the system layer (#28094)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dh79pyun authored Jul 21, 2023
1 parent f6ec7b9 commit 80be1a2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/platform/Tizen/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlatformManagerImpl>::_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)
Expand Down

0 comments on commit 80be1a2

Please sign in to comment.