From 14410cc6cb0587cee511e15c61de9ce94819deae Mon Sep 17 00:00:00 2001 From: Melanie Subbiah Date: Thu, 4 Aug 2016 16:09:23 -0700 Subject: [PATCH] Create trace points for thread events Summary: RequestContext update. Reviewed By: mibpl Differential Revision: D3604937 fbshipit-source-id: 07b315fe22a6dba40f0bab53c8092f35c172ae85 --- folly/io/async/Request.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/folly/io/async/Request.cpp b/folly/io/async/Request.cpp index 8ea7f3e3..dc46d9d8 100644 --- a/folly/io/async/Request.cpp +++ b/folly/io/async/Request.cpp @@ -105,16 +105,16 @@ void RequestContext::clearContextData(const std::string& val) { std::shared_ptr RequestContext::setContext( std::shared_ptr ctx) { - auto& prev = getStaticContext(); - if (ctx != prev) { + auto& curCtx = getStaticContext(); + if (ctx != curCtx) { using std::swap; - if (prev) { - prev->onUnset(); + if (curCtx) { + curCtx->onUnset(); } - if (ctx) { - ctx->onSet(); + swap(ctx, curCtx); + if (curCtx) { + curCtx->onSet(); } - swap(ctx, prev); } return ctx; } -- 2.34.1