Add two missing mutex-locks in MetaFileSystem.

See #19272
This commit is contained in:
Henrik Rydgård
2024-09-16 14:59:58 +02:00
parent 6328a4414b
commit b1fae3ccda
2 changed files with 5 additions and 1 deletions

View File

@@ -292,12 +292,14 @@ void MetaFileSystem::Mount(const std::string &prefix, std::shared_ptr<IFileSyste
fileSystems.push_back(x);
}
// Assumes the lock is held
void MetaFileSystem::UnmountAll() {
fileSystems.clear();
currentDir.clear();
}
void MetaFileSystem::Unmount(const std::string &prefix) {
std::lock_guard<std::recursive_mutex> guard(lock);
for (auto iter = fileSystems.begin(); iter != fileSystems.end(); iter++) {
if (iter->prefix == prefix) {
fileSystems.erase(iter);
@@ -325,6 +327,7 @@ IFileSystem *MetaFileSystem::GetSystemFromFilename(const std::string &filename)
}
IFileSystem *MetaFileSystem::GetSystem(const std::string &prefix) {
std::lock_guard<std::recursive_mutex> guard(lock);
for (auto it = fileSystems.begin(); it != fileSystems.end(); ++it) {
if (it->prefix == NormalizePrefix(prefix))
return it->system.get();