Bug 822398: Use PL_DHASH_REMOVE to remove an entry we're enumerating. r=kanru

This commit is contained in:
Chris Jones 2012-12-27 02:43:55 -08:00
Родитель 7c0322f4c3
Коммит da063875b4
1 изменённых файлов: 6 добавлений и 4 удалений

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

@ -66,10 +66,12 @@ CountWakeLocks(const uint64_t& aKey, LockCount aCount, void* aUserArg)
}
static PLDHashOperator
RemoveChildFromList(const nsAString& aKey, ProcessLockTable* aTable, void* aUserArg)
RemoveChildFromList(const nsAString& aKey, nsAutoPtr<ProcessLockTable>& aTable,
void* aUserArg)
{
MOZ_ASSERT(aUserArg);
PLDHashOperator op = PL_DHASH_NEXT;
uint64_t childID = *static_cast<uint64_t*>(aUserArg);
if (aTable->Get(childID, NULL)) {
aTable->Remove(childID);
@ -78,7 +80,7 @@ RemoveChildFromList(const nsAString& aKey, ProcessLockTable* aTable, void* aUser
WakeLockInformation info;
aTable->EnumerateRead(CountWakeLocks, &totalCount);
if (!totalCount.numLocks) {
sLockTable->Remove(aKey);
op = PL_DHASH_REMOVE;
}
info.numLocks() = totalCount.numLocks;
info.numHidden() = totalCount.numHidden;
@ -87,7 +89,7 @@ RemoveChildFromList(const nsAString& aKey, ProcessLockTable* aTable, void* aUser
}
}
return PL_DHASH_NEXT;
return op;
}
class ClearHashtableOnShutdown MOZ_FINAL : public nsIObserver {
@ -136,7 +138,7 @@ CleanupOnContentShutdown::Observe(nsISupports* aSubject, const char* aTopic, con
nsresult rv = props->GetPropertyAsUint64(NS_LITERAL_STRING("childID"),
&childID);
if (NS_SUCCEEDED(rv)) {
sLockTable->EnumerateRead(RemoveChildFromList, &childID);
sLockTable->Enumerate(RemoveChildFromList, &childID);
} else {
NS_WARNING("ipc:content-shutdown message without childID property");
}