提交 8984e5f8 编写于 作者: V Venkatesh Radhakrishnan

Fix race in sync point.

Summary:
The LoadDependency function does not take a lock when it runs
and it could be modifying data structures while other threads are
accessing it.

Test Plan: Run TSAN.

Reviewers: igor, sdong

Reviewed By: igor, sdong

Subscribers: dhruba

Differential Revision: https://reviews.facebook.net/D34095
上级 03b432d4
......@@ -14,6 +14,7 @@ SyncPoint* SyncPoint::GetInstance() {
}
void SyncPoint::LoadDependency(const std::vector<Dependency>& dependencies) {
std::unique_lock<std::mutex> lock(mutex_);
successors_.clear();
predecessors_.clear();
cleared_points_.clear();
......@@ -21,6 +22,7 @@ void SyncPoint::LoadDependency(const std::vector<Dependency>& dependencies) {
successors_[dependency.predecessor].push_back(dependency.successor);
predecessors_[dependency.successor].push_back(dependency.predecessor);
}
cv_.notify_all();
}
bool SyncPoint::PredecessorsAllCleared(const std::string& point) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册