From 6459323ce020c9e31ff9c407c4fc5f9bf6d0b0d0 Mon Sep 17 00:00:00 2001 From: Sagar Dhawan Date: Thu, 12 Aug 2021 17:38:00 -0700 Subject: [PATCH] Fix Watchable Event Manager Select crash on shutdown --- src/system/WatchableEventManagerSelect.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/system/WatchableEventManagerSelect.cpp b/src/system/WatchableEventManagerSelect.cpp index 926e572a3c524f..c5dd371488188e 100644 --- a/src/system/WatchableEventManagerSelect.cpp +++ b/src/system/WatchableEventManagerSelect.cpp @@ -77,6 +77,15 @@ CHIP_ERROR WatchableEventManager::Shutdown() while ((timer = mTimerList.PopEarliest()) != nullptr) { timer->Clear(); + +#if CHIP_SYSTEM_CONFIG_USE_DISPATCH + if (timer->mTimerSource != nullptr) + { + dispatch_source_cancel(timer->mTimerSource); + dispatch_release(timer->mTimerSource); + } +#endif // CHIP_SYSTEM_CONFIG_USE_DISPATCH + timer->Release(); } mWakeEvent.Close();