Do not capture RCTX in HHWheelTimer's underlying AsyncTimeout
Summary: We should only be capturing `folly::RequestContext` in HHWheelTimer's callback objects (already happens). And avoid capturing it in underlying AsyncTimeout. Notice that `AsyncTimeout::scheduleTimeout`/`scheduleTimeoutHighRes` APIs capture current `folly::RequestContext` and `AsyncTimeout::cancelTimeout` releases the captured `folly::RequestContext` Now, the way HHWheelTimer works, it re-uses one instance of AsyncTimeout for multiple timeouts. This opens up possibility for leaking lifetime of RCTX. Imagine first request A and then B schedule timeouts using same HHWheelTimer instnace. A's RCTX is captured by underlying AsyncTimeout. Next, request A is complete and we need to cancel its timeout. Notice, however that A's RCTX will not be destroyed as long as B is still running. That's the lifetime management leak. Reviewed By: jordalgo, andriigrynenko Differential Revision: D23260733 fbshipit-source-id: 0bdf79db40d34d6682e89e87ce30811ffccc8cbf
Showing
Please register or sign in to comment