From ebc6bc8ed7a1ea37d56e97484c8d70781a8216e5 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 16 Jan 2025 23:23:39 -0500 Subject: [PATCH] ramfs: Add iterator locking to index classes. --- src/add-ons/kernel/file_systems/ramfs/AttributeIndexImpl.cpp | 5 +++++ src/add-ons/kernel/file_systems/ramfs/LastModifiedIndex.cpp | 5 +++++ src/add-ons/kernel/file_systems/ramfs/SizeIndex.cpp | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/add-ons/kernel/file_systems/ramfs/AttributeIndexImpl.cpp b/src/add-ons/kernel/file_systems/ramfs/AttributeIndexImpl.cpp index 3d0ac20b6c..3eba57975b 100644 --- a/src/add-ons/kernel/file_systems/ramfs/AttributeIndexImpl.cpp +++ b/src/add-ons/kernel/file_systems/ramfs/AttributeIndexImpl.cpp @@ -17,6 +17,9 @@ #include "TwoKeyAVLTree.h" #include "Volume.h" +#include + + // compare_integral template static inline @@ -341,6 +344,7 @@ AttributeIndexImpl::InternalFind(const uint8 *key, size_t length) void AttributeIndexImpl::_AddIterator(Iterator *iterator) { + RecursiveLocker locker(fVolume->GetAttributeIteratorLock()); fIterators->Insert(iterator); } @@ -348,6 +352,7 @@ AttributeIndexImpl::_AddIterator(Iterator *iterator) void AttributeIndexImpl::_RemoveIterator(Iterator *iterator) { + RecursiveLocker locker(fVolume->GetAttributeIteratorLock()); fIterators->Remove(iterator); } diff --git a/src/add-ons/kernel/file_systems/ramfs/LastModifiedIndex.cpp b/src/add-ons/kernel/file_systems/ramfs/LastModifiedIndex.cpp index d6a5886e04..b149526d37 100644 --- a/src/add-ons/kernel/file_systems/ramfs/LastModifiedIndex.cpp +++ b/src/add-ons/kernel/file_systems/ramfs/LastModifiedIndex.cpp @@ -14,6 +14,9 @@ #include "NodeListener.h" #include "Volume.h" +#include + + // LastModifiedIndexPrimaryKey class LastModifiedIndexPrimaryKey { public: @@ -226,6 +229,7 @@ LastModifiedIndex::InternalFind(const uint8 *key, size_t length) void LastModifiedIndex::_AddIterator(Iterator *iterator) { + RecursiveLocker locker(fVolume->GetAttributeIteratorLock()); fIterators->Insert(iterator); } @@ -233,6 +237,7 @@ LastModifiedIndex::_AddIterator(Iterator *iterator) void LastModifiedIndex::_RemoveIterator(Iterator *iterator) { + RecursiveLocker locker(fVolume->GetAttributeIteratorLock()); fIterators->Remove(iterator); } diff --git a/src/add-ons/kernel/file_systems/ramfs/SizeIndex.cpp b/src/add-ons/kernel/file_systems/ramfs/SizeIndex.cpp index bd67eb7045..44231eb8b7 100644 --- a/src/add-ons/kernel/file_systems/ramfs/SizeIndex.cpp +++ b/src/add-ons/kernel/file_systems/ramfs/SizeIndex.cpp @@ -13,6 +13,9 @@ #include "SizeIndex.h" #include "Volume.h" +#include + + // SizeIndexPrimaryKey class SizeIndexPrimaryKey { public: @@ -225,6 +228,7 @@ SizeIndex::InternalFind(const uint8 *key, size_t length) void SizeIndex::_AddIterator(Iterator *iterator) { + RecursiveLocker locker(fVolume->GetAttributeIteratorLock()); fIterators->Insert(iterator); } @@ -232,6 +236,7 @@ SizeIndex::_AddIterator(Iterator *iterator) void SizeIndex::_RemoveIterator(Iterator *iterator) { + RecursiveLocker locker(fVolume->GetAttributeIteratorLock()); fIterators->Remove(iterator); }