From a93b1f39a4e39fef73ffad8a9725e46bd93b7b07 Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Mon, 9 Nov 2015 10:39:22 -0800 Subject: [PATCH] Make sure there are no outstanding timers in the destructor Summary: This is the solution for our `HHWheelTimer` crashes, as suggested in D2617966#25. djwatson also mentioned that maybe there should be some logging in the destructor if there are outstanding callbacks. I couldn't think of anything that would add to the `assert` that already exists in `destroy`. I'm open to suggestions though. Reviewed By: djwatson Differential Revision: D2628154 fb-gh-sync-id: f3db6e9384517c9bf3cbb60af8c1e711703a07fa --- folly/io/async/HHWheelTimer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/folly/io/async/HHWheelTimer.cpp b/folly/io/async/HHWheelTimer.cpp index c62fb93d..65c3fff6 100644 --- a/folly/io/async/HHWheelTimer.cpp +++ b/folly/io/async/HHWheelTimer.cpp @@ -94,10 +94,12 @@ HHWheelTimer::HHWheelTimer(folly::EventBase* eventBase, } HHWheelTimer::~HHWheelTimer() { + CHECK(count_ == 0); } void HHWheelTimer::destroy() { assert(count_ == 0); + cancelAll(); DelayedDestruction::destroy(); } -- 2.34.1