Create trace points for thread events
authorMelanie Subbiah <melaniesubbiah@fb.com>
Thu, 4 Aug 2016 23:09:23 +0000 (16:09 -0700)
committerFacebook Github Bot 6 <facebook-github-bot-6-bot@fb.com>
Thu, 4 Aug 2016 23:23:32 +0000 (16:23 -0700)
Summary: RequestContext update.

Reviewed By: mibpl

Differential Revision: D3604937

fbshipit-source-id: 07b315fe22a6dba40f0bab53c8092f35c172ae85

folly/io/async/Request.cpp

index 8ea7f3e311789d82d576a4b401d6eced3114d24a..dc46d9d87c841cccec2c9719fa19cab2388a3e6e 100644 (file)
@@ -105,16 +105,16 @@ void RequestContext::clearContextData(const std::string& val) {
 
 std::shared_ptr<RequestContext> RequestContext::setContext(
     std::shared_ptr<RequestContext> 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;
 }