Commit 4941d624 authored by Matthieu Martin's avatar Matthieu Martin Committed by Facebook Github Bot

Revert "Avoid set/onset calls while shallow copying RequestContext"

Summary: This added significant cost, it will take effort to deploy, reverting for now

Differential Revision: D9007024

fbshipit-source-id: 04074b09a1a2b7f9b57e3d755a2754657dda21c2
parent 4d3071a3
......@@ -131,9 +131,13 @@ std::shared_ptr<RequestContext> RequestContext::setContext(
auto& curCtx = getStaticContext();
if (ctx != curCtx) {
FOLLY_SDT(folly, request_context_switch_before, curCtx.get(), ctx.get());
get()->onUnset();
if (curCtx) {
curCtx->onUnset();
}
std::swap(ctx, curCtx);
get()->onSet();
if (curCtx) {
curCtx->onSet();
}
}
return ctx;
}
......
......@@ -126,8 +126,9 @@ TEST(RequestContext, defaultContext) {
EXPECT_FALSE(hasData());
}
EXPECT_EQ(10, getData().data_);
EXPECT_EQ(2, getData().set_);
EXPECT_EQ(1, getData().unset_);
// TODO: should be 2/1
EXPECT_EQ(1, getData().set_);
EXPECT_EQ(0, getData().unset_);
}
TEST(RequestContext, setIfAbsentTest) {
......
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