From: Chad Parry Date: Mon, 9 Nov 2015 18:39:22 +0000 (-0800) Subject: Make sure there are no outstanding timers in the destructor X-Git-Tag: deprecate-dynamic-initializer~270 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a93b1f39a4e39fef73ffad8a9725e46bd93b7b07;p=folly.git 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 --- 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(); }