Commit 98a70c4d authored by GaneshRapolu's avatar GaneshRapolu Committed by Facebook GitHub Bot

Fix data race/UB in RCU documentation example (#1348)

Summary:
The read of globalConfigData outside of sm.lock() races with any other writer that is modifying
globalConfigData inside of sm.lock(). This is a documentation only change.
Pull Request resolved: https://github.com/facebook/folly/pull/1348

Reviewed By: paulmckrcu

Differential Revision: D20864073

Pulled By: yfeldblum

fbshipit-source-id: 31b7ed469716acb35913df9a71585c2a59e50bea
parent 674c2b7f
......@@ -67,9 +67,10 @@
// void writer() {
// while (true) {
// std::this_thread::sleep_for(std::chrono::seconds(60));
// ConfigData* oldConfigData = globalConfigData;
// ConfigData* oldConfigData;
// ConfigData* newConfigData = loadConfigDataFromRemoteServer();
// sm.lock();
// oldConfigData = globalConfigData;
// globalConfigData = newConfigData;
// sm.unlock();
// delete oldConfigData;
......
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