Skip to content

Commit

Permalink
Fix platform manager impls to correctly flag tasks as shut down.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Jul 10, 2022
1 parent 0b7ee89 commit 9fbaf82
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_RunEventLoop(void)
eventReceived = xQueueReceive(mChipEventQueue, &event, 0);
}
}

#if defined(INCLUDE_vTaskDelete) && INCLUDE_vTaskDelete
if (mEventLoopTask)
{
vTaskDelete(mEventLoopTask);
mEventLoopTask = nullptr;
}
#endif // INCLUDE_vTaskDelete
}

template <class ImplClass>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class GenericPlatformManagerImpl_POSIX : public GenericPlatformManagerImpl<ImplC
struct sched_param mChipTaskSchedParam;

#if CHIP_STACK_LOCK_TRACKING_ENABLED
bool mMainLoopStarted = false;
bool mChipStackIsLocked = false;
pthread_t mChipStackLockOwnerThread;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void GenericPlatformManagerImpl_POSIX<ImplClass>::_UnlockChipStack()
template <class ImplClass>
bool GenericPlatformManagerImpl_POSIX<ImplClass>::_IsChipStackLockedByCurrentThread() const
{
return !mMainLoopStarted || (mChipStackIsLocked && (pthread_equal(pthread_self(), mChipStackLockOwnerThread)));
return !mHasValidChipTask || (mChipStackIsLocked && (pthread_equal(pthread_self(), mChipStackLockOwnerThread)));
}
#endif

Expand Down Expand Up @@ -201,7 +201,6 @@ template <class ImplClass>
void * GenericPlatformManagerImpl_POSIX<ImplClass>::EventLoopTaskMain(void * arg)
{
ChipLogDetail(DeviceLayer, "CHIP task running");
static_cast<GenericPlatformManagerImpl_POSIX<ImplClass> *>(arg)->Impl()->mMainLoopStarted = true;
static_cast<GenericPlatformManagerImpl_POSIX<ImplClass> *>(arg)->Impl()->RunEventLoop();
return nullptr;
}
Expand Down

0 comments on commit 9fbaf82

Please sign in to comment.