forked from OSchip/llvm-project
DirectoryWatcher: close a possible window of race on Windows
The initial scan occurring before the watcher is ready allows a race condition where a change occurs before the initial scan completes. Ensure that we wait for the watcher to begin executing the initial scan. Addresses some feedback from Adrian McCarthy in post-commit review.
This commit is contained in:
parent
680d3f8f17
commit
a6948da86a
|
@ -133,6 +133,9 @@ DirectoryWatcherWindows::~DirectoryWatcherWindows() {
|
|||
}
|
||||
|
||||
void DirectoryWatcherWindows::InitialScan() {
|
||||
std::unique_lock<std::mutex> lock(Mutex);
|
||||
Ready.wait(lock, [this] { return this->WatcherActive; });
|
||||
|
||||
Callback(getAsFileEvents(scanDirectory(Path.data())), /*IsInitial=*/true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue