(Wangle) Fix possible race in updating FSM state
[folly.git] / folly / futures / detail / FSM.h
index ce77c551173637f85efe3f8624432c577b172056..b706ed04503e414ed780985a14dee70b980c564d 100644 (file)
@@ -55,12 +55,12 @@ public:
     if (!mutex_.try_lock()) {
       mutex_.lock();
     }
-    if (state_.load(std::memory_order_relaxed) != A) {
+    if (state_.load(std::memory_order_acquire) != A) {
       mutex_.unlock();
       return false;
     }
     action();
-    state_.store(B, std::memory_order_relaxed);
+    state_.store(B, std::memory_order_release);
     mutex_.unlock();
     return true;
   }