* Modify LocatableEntry and Domain to use a similar strategy as
TeamMemoryBlockManager to avert a race condition where an entry could be acquired while another thread was about to delete it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42093 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -185,10 +185,16 @@ private:
|
|||||||
|
|
||||||
virtual void LocatableEntryUnused(LocatableEntry* entry)
|
virtual void LocatableEntryUnused(LocatableEntry* entry)
|
||||||
{
|
{
|
||||||
fManager->Lock();
|
AutoLocker<FileManager> lock(fManager);
|
||||||
if (fEntries.Lookup(EntryPath(entry)) == entry)
|
if (fEntries.Lookup(EntryPath(entry)) == entry)
|
||||||
fEntries.Remove(entry);
|
fEntries.Remove(entry);
|
||||||
fManager->Unlock();
|
else {
|
||||||
|
DeadEntryList::Iterator iterator = fDeadEntries.GetIterator();
|
||||||
|
while (iterator.HasNext()) {
|
||||||
|
if (iterator.Next() == entry)
|
||||||
|
fDeadEntries.Remove(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _LocateDirectory(LocatableDirectory* directory,
|
bool _LocateDirectory(LocatableDirectory* directory,
|
||||||
@@ -285,8 +291,11 @@ private:
|
|||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
file->AcquireReference();
|
if (file->AcquireReference() == 1) {
|
||||||
return file;
|
fEntries.Remove(file);
|
||||||
|
fDeadEntries.Insert(file);
|
||||||
|
} else
|
||||||
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no such file yet -- create it
|
// no such file yet -- create it
|
||||||
@@ -452,6 +461,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
FileManager* fManager;
|
FileManager* fManager;
|
||||||
LocatableEntryTable fEntries;
|
LocatableEntryTable fEntries;
|
||||||
|
DeadEntryList fDeadEntries;
|
||||||
bool fIsLocal;
|
bool fIsLocal;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,11 @@
|
|||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
#include <util/DoublyLinkedList.h>
|
||||||
#include <util/OpenHashTable.h>
|
#include <util/OpenHashTable.h>
|
||||||
|
|
||||||
|
|
||||||
|
class LocatableEntry;
|
||||||
class LocatableFile;
|
class LocatableFile;
|
||||||
class SourceFile;
|
class SourceFile;
|
||||||
|
|
||||||
@@ -53,6 +55,7 @@ private:
|
|||||||
struct SourceFileHashDefinition;
|
struct SourceFileHashDefinition;
|
||||||
|
|
||||||
typedef BOpenHashTable<EntryHashDefinition> LocatableEntryTable;
|
typedef BOpenHashTable<EntryHashDefinition> LocatableEntryTable;
|
||||||
|
typedef DoublyLinkedList<LocatableEntry> DeadEntryList;
|
||||||
typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
|
typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
|
||||||
|
|
||||||
friend struct SourceFileEntry;
|
friend struct SourceFileEntry;
|
||||||
|
|||||||
Reference in New Issue
Block a user