@@ -46,18 +46,7 @@ CHIP_ERROR GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_InitChipStack(void)
46
46
47
47
vTaskSetTimeOutState (&mNextTimerBaseTime );
48
48
mNextTimerDurationTicks = 0 ;
49
- // TODO: This nulling out of mEventLoopTask should happen when we shut down
50
- // the task, not here!
51
- mEventLoopTask = NULL ;
52
- #if defined(CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING) && CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING
53
- mBackgroundEventLoopTask = NULL ;
54
- #endif
55
- mChipTimerActive = false ;
56
-
57
- // We support calling Shutdown followed by InitChipStack, because some tests
58
- // do that. To keep things simple for existing consumers, we keep not
59
- // destroying our lock and queue in shutdown, but rather check whether they
60
- // already exist here before trying to create them.
49
+ mChipTimerActive = false ;
61
50
62
51
if (mChipStackLock == NULL )
63
52
{
@@ -277,10 +266,11 @@ template <class ImplClass>
277
266
void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::EventLoopTaskMain(void * arg)
278
267
{
279
268
ChipLogDetail (DeviceLayer, " CHIP event task running" );
280
- static_cast <GenericPlatformManagerImpl_FreeRTOS<ImplClass> *>(arg)->Impl ()->RunEventLoop ();
281
- // TODO: At this point, should we not
282
- // vTaskDelete(static_cast<GenericPlatformManagerImpl_FreeRTOS<ImplClass> *>(arg)->mEventLoopTask)?
283
- // Or somehow get our caller to do it once this thread is joined?
269
+ GenericPlatformManagerImpl_FreeRTOS<ImplClass> * platformManager =
270
+ static_cast <GenericPlatformManagerImpl_FreeRTOS<ImplClass> *>(arg);
271
+ platformManager->Impl ()->RunEventLoop ();
272
+ vTaskDelete (NULL );
273
+ platformManager->mEventLoopTask = NULL ;
284
274
}
285
275
286
276
template <class ImplClass >
@@ -376,7 +366,11 @@ template <class ImplClass>
376
366
void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::BackgroundEventLoopTaskMain(void * arg)
377
367
{
378
368
ChipLogDetail (DeviceLayer, " CHIP background task running" );
379
- static_cast <GenericPlatformManagerImpl_FreeRTOS<ImplClass> *>(arg)->Impl ()->RunBackgroundEventLoop ();
369
+ GenericPlatformManagerImpl_FreeRTOS<ImplClass> * platformManager =
370
+ static_cast <GenericPlatformManagerImpl_FreeRTOS<ImplClass> *>(arg);
371
+ platformManager->Impl ()->RunBackgroundEventLoop ();
372
+ vTaskDelete (NULL );
373
+ platformManager->mBackgroundEventLoopTask = NULL ;
380
374
}
381
375
#endif
382
376
@@ -416,6 +410,20 @@ void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::PostEventFromISR(const Chip
416
410
template <class ImplClass >
417
411
void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_Shutdown(void )
418
412
{
413
+ if (mChipEventQueue )
414
+ {
415
+ vQueueDelete (mChipEventQueue );
416
+ mChipEventQueue = NULL ;
417
+ }
418
+ #if defined(CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING) && CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING
419
+ if (mBackgroundEventQueue )
420
+ {
421
+ vQueueDelete (mBackgroundEventQueue );
422
+ mBackgroundEventQueue = NULL ;
423
+ }
424
+ #endif
425
+ vSemaphoreDelete (mChipStackLock );
426
+ mChipStackLock = NULL ;
419
427
GenericPlatformManagerImpl<ImplClass>::_Shutdown ();
420
428
}
421
429
0 commit comments