Commit 4ffd39d6 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot 1

Fix one more race in Promise::setTry

Summary:
Baton::post has to be the last step of Promise::setTry. If Promise is not owned by
the posting thread, it may be destroyed right after Baton::post is called.

Reviewed By: pavlo-fb

Differential Revision: D3312506

fbshipit-source-id: 6d5c3f0925c3bb9cd3f981e7550f888d5ed76189
parent 72320612
......@@ -63,9 +63,9 @@ void Promise<T>::setTry(folly::Try<T>&& t) {
*value_ = std::move(t);
value_ = nullptr;
// Baton::post has to be the last step here, since if Promise is not owned by
// the posting thread, it may be destroyed right after Baton::post is called.
baton_->post();
baton_ = nullptr;
}
template <class T>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment