Commit 54b202c0 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

In Futures Core, destroy context when destroying callback

Summary:
[Folly] In Futures Core, destroy context when destroying callback since they basically go together.

Also removes expectations in an Eden FS test case which affirm the old behavior, along with a TODO to remove the expectations once the affirmed behavior is fixed.

Reviewed By: marshallcline

Differential Revision: D8347040

fbshipit-source-id: ed9fec932ad1e0aa1e40675cf70081d19bbe4325
parent cd498c15
...@@ -274,8 +274,8 @@ class Core final { ...@@ -274,8 +274,8 @@ class Core final {
/// executor or if the executor is inline). /// executor or if the executor is inline).
template <typename F> template <typename F>
void setCallback(F&& func) { void setCallback(F&& func) {
context_ = RequestContext::saveContext();
callback_ = std::forward<F>(func); callback_ = std::forward<F>(func);
context_ = RequestContext::saveContext();
auto state = state_.load(std::memory_order_acquire); auto state = state_.load(std::memory_order_acquire);
while (true) { while (true) {
...@@ -534,6 +534,7 @@ class Core final { ...@@ -534,6 +534,7 @@ class Core final {
} else { } else {
attached_++; attached_++;
SCOPE_EXIT { SCOPE_EXIT {
context_ = {};
callback_ = {}; callback_ = {};
detachOne(); detachOne();
}; };
...@@ -552,6 +553,7 @@ class Core final { ...@@ -552,6 +553,7 @@ class Core final {
void derefCallback() noexcept { void derefCallback() noexcept {
if (--callbackReferences_ == 0) { if (--callbackReferences_ == 0) {
context_ = {};
callback_ = {}; callback_ = {};
} }
} }
......
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