[FileCollector] Lock Mutex in copyFiles

We should synchronize reading of VFSWriter's data with the rest of the methods.

Differential revision: https://reviews.llvm.org/D78956
This commit is contained in:
Jan Korous 2020-04-28 10:43:17 -07:00
parent 6068fc0c0b
commit a077fc20b4
2 changed files with 3 additions and 1 deletions

View File

@ -69,7 +69,7 @@ protected:
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.

View File

@ -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 =