Make sure there are no outstanding timers in the destructor
authorChad Parry <cparry@fb.com>
Mon, 9 Nov 2015 18:39:22 +0000 (10:39 -0800)
committerfacebook-github-bot-9 <folly-bot@fb.com>
Mon, 9 Nov 2015 19:20:24 +0000 (11:20 -0800)
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

index c62fb93df58b4d41dd0e2fd6d5a859ebefc44c4a..65c3fff6e936f078dfbb57a53eda2e6e806c6d5e 100644 (file)
@@ -94,10 +94,12 @@ HHWheelTimer::HHWheelTimer(folly::EventBase* eventBase,
 }
 
 HHWheelTimer::~HHWheelTimer() {
+  CHECK(count_ == 0);
 }
 
 void HHWheelTimer::destroy() {
   assert(count_ == 0);
+  cancelAll();
   DelayedDestruction::destroy();
 }