mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[DependencyScanning] Isolate 'DependencyScanningTool' reset operations
Guard 'resetCache' and 'resetDiagnostics' as critical sections using 'DependencyScanningToolStateLock'. Otherwise there's a chance that one thread in the scanner is doing a reset on the diagnostic consumer, while some other thread is adding this diagnostic consumer to another scan instance which may also be populating said consumer at the time. Similarly, for resetting 'ScanningService' though it is much more unlikely to be reset while in-use by other scanning actions.
This commit is contained in:
@@ -215,10 +215,12 @@ bool DependencyScanningTool::loadCache(llvm::StringRef path) {
|
||||
}
|
||||
|
||||
void DependencyScanningTool::resetCache() {
|
||||
llvm::sys::SmartScopedLock<true> Lock(DependencyScanningToolStateLock);
|
||||
ScanningService.reset(new SwiftDependencyScanningService());
|
||||
}
|
||||
|
||||
void DependencyScanningTool::resetDiagnostics() {
|
||||
llvm::sys::SmartScopedLock<true> Lock(DependencyScanningToolStateLock);
|
||||
CDC.reset();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user