Bug 1095474 - Intermittent /indexedDB/test/test_file_replace.html | application terminated with exit code 1; r=bent

This commit is contained in:
Jan Varga 2014-11-13 10:43:22 +01:00
Родитель 1b048b4316
Коммит ea37e37e95
3 изменённых файлов: 38 добавлений и 36 удалений

Просмотреть файл

@ -8734,16 +8734,15 @@ FileManager::Invalidate()
{
public:
static PLDHashOperator
CopyToTArray(const uint64_t& aKey, FileInfo* aValue, void* aUserArg)
ClearDBRefs(const uint64_t& aKey, FileInfo*& aValue, void* aUserArg)
{
MOZ_ASSERT(aValue);
auto* array = static_cast<FallibleTArray<FileInfo*>*>(aUserArg);
MOZ_ASSERT(array);
if (aValue->LockedClearDBRefs()) {
return PL_DHASH_NEXT;
}
MOZ_ALWAYS_TRUE(array->AppendElement(aValue));
return PL_DHASH_NEXT;
return PL_DHASH_REMOVE;
}
};
@ -8752,26 +8751,12 @@ FileManager::Invalidate()
return NS_ERROR_UNEXPECTED;
}
FallibleTArray<FileInfo*> fileInfos;
{
MutexAutoLock lock(IndexedDatabaseManager::FileMutex());
MutexAutoLock lock(IndexedDatabaseManager::FileMutex());
MOZ_ASSERT(!mInvalidated);
mInvalidated = true;
MOZ_ASSERT(!mInvalidated);
mInvalidated = true;
if (NS_WARN_IF(!fileInfos.SetCapacity(mFileInfos.Count()))) {
return NS_ERROR_OUT_OF_MEMORY;
}
mFileInfos.EnumerateRead(Helper::CopyToTArray, &fileInfos);
}
for (uint32_t count = fileInfos.Length(), index = 0; index < count; index++) {
FileInfo* fileInfo = fileInfos[index];
MOZ_ASSERT(fileInfo);
fileInfo->ClearDBRefs();
}
mFileInfos.Enumerate(Helper::ClearDBRefs, nullptr);
return NS_OK;
}

Просмотреть файл

@ -130,15 +130,13 @@ FileInfo::GetReferences(int32_t* aRefCnt,
void
FileInfo::UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
int32_t aDelta,
bool aClear)
int32_t aDelta)
{
// XXX This can go away once DOM objects no longer hold FileInfo objects...
// Looking at you, IDBMutableFile...
if (IndexedDatabaseManager::IsClosed()) {
MOZ_ASSERT(&aRefCount == &mRefCnt);
MOZ_ASSERT(aDelta == 1 || aDelta == -1);
MOZ_ASSERT(!aClear);
if (aDelta > 0) {
++aRefCount;
@ -158,7 +156,7 @@ FileInfo::UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
{
MutexAutoLock lock(IndexedDatabaseManager::FileMutex());
aRefCount = aClear ? 0 : aRefCount + aDelta;
aRefCount = aRefCount + aDelta;
if (mRefCnt + mDBRefCnt + mSliceRefCnt > 0) {
return;
@ -176,6 +174,29 @@ FileInfo::UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
delete this;
}
bool
FileInfo::LockedClearDBRefs()
{
MOZ_ASSERT(!IndexedDatabaseManager::IsClosed());
IndexedDatabaseManager::FileMutex().AssertCurrentThreadOwns();
mDBRefCnt = 0;
if (mRefCnt || mSliceRefCnt) {
return true;
}
// In this case, we are not responsible for removing the file info from the
// hashtable. It's up to FileManager which is the only caller of this method.
MOZ_ASSERT(mFileManager->Invalidated());
delete this;
return false;
}
void
FileInfo::Cleanup()
{

Просмотреть файл

@ -50,12 +50,6 @@ public:
UpdateReferences(mDBRefCnt, aDelta);
}
void
ClearDBRefs()
{
UpdateReferences(mDBRefCnt, 0, true);
}
void
UpdateSliceRefs(int32_t aDelta)
{
@ -80,8 +74,10 @@ protected:
private:
void
UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
int32_t aDelta,
bool aClear = false);
int32_t aDelta);
bool
LockedClearDBRefs();
void
Cleanup();