Callbacks should ref the HHWheelTimer
authorChad Parry <cparry@fb.com>
Fri, 6 Nov 2015 19:52:10 +0000 (11:52 -0800)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Fri, 6 Nov 2015 20:20:23 +0000 (12:20 -0800)
commitcb65a6b273ae8c050333600816557755d488b63c
treed8fd4987927f30eb8dab69313c22269df5828633
parent06b04cb147733a296278c42c5d0364ec3078e1c9
Callbacks should ref the HHWheelTimer

Summary: Callbacks sometimes outlive the `HHWheelTimer` that they reference. Then the `Callback` tries to reference the dead `HHWheelTimer` and it could either misbehave or crash. This was caught reliably by ASAN tests.

Since `HHWheelTimer` already supports intrusive ref counting, the solution is to acquire a reference within the `Callback`.

Reviewed By: djwatson

Differential Revision: D2617966

fb-gh-sync-id: 02be9ffc5851c269d5933288a17ad394b33ac2dd
folly/io/async/HHWheelTimer.cpp
folly/io/async/HHWheelTimer.h