* 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:
Rene Gollent 2011-06-11 01:00:25 +00:00
parent 2e8aa19c63
commit c1ae7caf60
2 changed files with 17 additions and 4 deletions

View File

@ -185,10 +185,16 @@ private:
virtual void LocatableEntryUnused(LocatableEntry* entry)
{
fManager->Lock();
AutoLocker<FileManager> lock(fManager);
if (fEntries.Lookup(EntryPath(entry)) == 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,
@ -285,7 +291,10 @@ private:
if (file == NULL)
return NULL;
file->AcquireReference();
if (file->AcquireReference() == 1) {
fEntries.Remove(file);
fDeadEntries.Insert(file);
} else
return file;
}
@ -452,6 +461,7 @@ private:
private:
FileManager* fManager;
LocatableEntryTable fEntries;
DeadEntryList fDeadEntries;
bool fIsLocal;
};

View File

@ -8,9 +8,11 @@
#include <Locker.h>
#include <String.h>
#include <util/DoublyLinkedList.h>
#include <util/OpenHashTable.h>
class LocatableEntry;
class LocatableFile;
class SourceFile;
@ -53,6 +55,7 @@ private:
struct SourceFileHashDefinition;
typedef BOpenHashTable<EntryHashDefinition> LocatableEntryTable;
typedef DoublyLinkedList<LocatableEntry> DeadEntryList;
typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
friend struct SourceFileEntry;