ramfs: Add iterator locking to index classes.

This commit is contained in:
Augustin Cavalier 2025-01-16 23:23:39 -05:00
parent 5ac03c3714
commit ebc6bc8ed7
3 changed files with 15 additions and 0 deletions

View File

@ -17,6 +17,9 @@
#include "TwoKeyAVLTree.h" #include "TwoKeyAVLTree.h"
#include "Volume.h" #include "Volume.h"
#include <util/AutoLock.h>
// compare_integral // compare_integral
template<typename Key> template<typename Key>
static inline static inline
@ -341,6 +344,7 @@ AttributeIndexImpl::InternalFind(const uint8 *key, size_t length)
void void
AttributeIndexImpl::_AddIterator(Iterator *iterator) AttributeIndexImpl::_AddIterator(Iterator *iterator)
{ {
RecursiveLocker locker(fVolume->GetAttributeIteratorLock());
fIterators->Insert(iterator); fIterators->Insert(iterator);
} }
@ -348,6 +352,7 @@ AttributeIndexImpl::_AddIterator(Iterator *iterator)
void void
AttributeIndexImpl::_RemoveIterator(Iterator *iterator) AttributeIndexImpl::_RemoveIterator(Iterator *iterator)
{ {
RecursiveLocker locker(fVolume->GetAttributeIteratorLock());
fIterators->Remove(iterator); fIterators->Remove(iterator);
} }

View File

@ -14,6 +14,9 @@
#include "NodeListener.h" #include "NodeListener.h"
#include "Volume.h" #include "Volume.h"
#include <util/AutoLock.h>
// LastModifiedIndexPrimaryKey // LastModifiedIndexPrimaryKey
class LastModifiedIndexPrimaryKey { class LastModifiedIndexPrimaryKey {
public: public:
@ -226,6 +229,7 @@ LastModifiedIndex::InternalFind(const uint8 *key, size_t length)
void void
LastModifiedIndex::_AddIterator(Iterator *iterator) LastModifiedIndex::_AddIterator(Iterator *iterator)
{ {
RecursiveLocker locker(fVolume->GetAttributeIteratorLock());
fIterators->Insert(iterator); fIterators->Insert(iterator);
} }
@ -233,6 +237,7 @@ LastModifiedIndex::_AddIterator(Iterator *iterator)
void void
LastModifiedIndex::_RemoveIterator(Iterator *iterator) LastModifiedIndex::_RemoveIterator(Iterator *iterator)
{ {
RecursiveLocker locker(fVolume->GetAttributeIteratorLock());
fIterators->Remove(iterator); fIterators->Remove(iterator);
} }

View File

@ -13,6 +13,9 @@
#include "SizeIndex.h" #include "SizeIndex.h"
#include "Volume.h" #include "Volume.h"
#include <util/AutoLock.h>
// SizeIndexPrimaryKey // SizeIndexPrimaryKey
class SizeIndexPrimaryKey { class SizeIndexPrimaryKey {
public: public:
@ -225,6 +228,7 @@ SizeIndex::InternalFind(const uint8 *key, size_t length)
void void
SizeIndex::_AddIterator(Iterator *iterator) SizeIndex::_AddIterator(Iterator *iterator)
{ {
RecursiveLocker locker(fVolume->GetAttributeIteratorLock());
fIterators->Insert(iterator); fIterators->Insert(iterator);
} }
@ -232,6 +236,7 @@ SizeIndex::_AddIterator(Iterator *iterator)
void void
SizeIndex::_RemoveIterator(Iterator *iterator) SizeIndex::_RemoveIterator(Iterator *iterator)
{ {
RecursiveLocker locker(fVolume->GetAttributeIteratorLock());
fIterators->Remove(iterator); fIterators->Remove(iterator);
} }