fix destruction race for terminateLoopSoon
Summary: Calling `EventBase::terminateLoopSoon` from a different thread should be a thread safe operation when there is a concurrently executing `loopForever`, immediately followed by `EventBase` destruction. Today, we first set the stop_ flag to stop the event loop, then post a message to tell eventlib to stop its event loop. ... but IIUC the stop_ flag is the thing that makes the `while()` loop to keep going forever. Thus setting it before message is posted may result in the `loopForever` terminate and underlying EventBase destroyed before we are able to post a message to eventlib. The fix is to set `stop_ = true` in loop. Reviewed By: yfeldblum, andriigrynenko Differential Revision: D29143212 fbshipit-source-id: f102fbad31653dd7525eff0f70600aa71ae02534
Showing
Please register or sign in to comment