Skip to content

Commit

Permalink
[FileCollector] Lock Mutex in copyFiles
Browse files Browse the repository at this point in the history
We should synchronize reading of VFSWriter's data with the rest of the methods.

Differential revision: https://reviews.llvm.org/D78956
  • Loading branch information
jkorous-apple committed Apr 28, 2020
1 parent 0de7ddb commit 1e43cab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/include/llvm/Support/FileCollector.h
Expand Up @@ -69,7 +69,7 @@ class FileCollector {
addDirectoryImpl(const llvm::Twine &Dir,
IntrusiveRefCntPtr<vfs::FileSystem> FS, std::error_code &EC);

/// Synchronizes adding files.
/// Synchronizes access to Seen, VFSWriter and SymlinkMap.
std::mutex Mutex;

/// The root directory where files are copied.
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/FileCollector.cpp
Expand Up @@ -150,6 +150,8 @@ copyAccessAndModificationTime(StringRef Filename,
}

std::error_code FileCollector::copyFiles(bool StopOnError) {
std::lock_guard<std::mutex> lock(Mutex);

for (auto &entry : VFSWriter.getMappings()) {
// Create directory tree.
if (std::error_code EC =
Expand Down

0 comments on commit 1e43cab

Please sign in to comment.