Backed out changeset 12b059c5afc2 (bug 1055369) for frequent asserts across all test suites.

This commit is contained in:
Ryan VanderMeulen
2015-02-24 11:40:22 -05:00
parent 332185c88d
commit c05b1972ff
4 changed files with 40 additions and 19 deletions

View File

@@ -310,6 +310,7 @@ CacheFileHandles::~CacheFileHandles()
nsresult
CacheFileHandles::GetHandle(const SHA1Sum::Hash *aHash,
bool aReturnDoomed,
CacheFileHandle **_retval)
{
MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
@@ -343,11 +344,15 @@ CacheFileHandles::GetHandle(const SHA1Sum::Hash *aHash,
if (handle->IsDoomed()) {
LOG(("CacheFileHandles::GetHandle() hash=%08x%08x%08x%08x%08x "
"found doomed handle %p, entry %p", LOGSHA1(aHash), handle.get(), entry));
return NS_ERROR_NOT_AVAILABLE;
}
LOG(("CacheFileHandles::GetHandle() hash=%08x%08x%08x%08x%08x "
"found handle %p, entry %p", LOGSHA1(aHash), handle.get(), entry));
// If the consumer doesn't want doomed handles, exit with NOT_AVAIL.
if (!aReturnDoomed) {
return NS_ERROR_NOT_AVAILABLE;
}
} else {
LOG(("CacheFileHandles::GetHandle() hash=%08x%08x%08x%08x%08x "
"found handle %p, entry %p", LOGSHA1(aHash), handle.get(), entry));
}
handle.forget(_retval);
return NS_OK;
@@ -805,7 +810,7 @@ public:
if (!mIOMan) {
rv = NS_ERROR_NOT_INITIALIZED;
} else {
rv = mIOMan->DoomFileByKeyInternal(&mHash);
rv = mIOMan->DoomFileByKeyInternal(&mHash, false);
mIOMan = nullptr;
}
@@ -1570,7 +1575,7 @@ CacheFileIOManager::OpenFileInternal(const SHA1Sum::Hash *aHash,
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<CacheFileHandle> handle;
mHandles.GetHandle(aHash, getter_AddRefs(handle));
mHandles.GetHandle(aHash, false, getter_AddRefs(handle));
if ((aFlags & (OPEN | CREATE | CREATE_NEW)) == CREATE_NEW) {
if (handle) {
@@ -2069,10 +2074,11 @@ CacheFileIOManager::DoomFileByKey(const nsACString &aKey,
}
nsresult
CacheFileIOManager::DoomFileByKeyInternal(const SHA1Sum::Hash *aHash)
CacheFileIOManager::DoomFileByKeyInternal(const SHA1Sum::Hash *aHash,
bool aFailIfAlreadyDoomed)
{
LOG(("CacheFileIOManager::DoomFileByKeyInternal() [hash=%08x%08x%08x%08x%08x]"
, LOGSHA1(aHash)));
LOG(("CacheFileIOManager::DoomFileByKeyInternal() [hash=%08x%08x%08x%08x%08x,"
" failIfAlreadyDoomed=%d]", LOGSHA1(aHash), aFailIfAlreadyDoomed));
MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
@@ -2088,11 +2094,15 @@ CacheFileIOManager::DoomFileByKeyInternal(const SHA1Sum::Hash *aHash)
// Find active handle
nsRefPtr<CacheFileHandle> handle;
mHandles.GetHandle(aHash, getter_AddRefs(handle));
mHandles.GetHandle(aHash, true, getter_AddRefs(handle));
if (handle) {
handle->Log();
if (handle->IsDoomed()) {
return aFailIfAlreadyDoomed ? NS_ERROR_NOT_AVAILABLE : NS_OK;
}
return DoomFileInternal(handle);
}
@@ -2234,7 +2244,7 @@ CacheFileIOManager::GetEntryInfo(const SHA1Sum::Hash *aHash,
nsAutoCString uriSpec;
nsRefPtr<CacheFileHandle> handle;
ioMan->mHandles.GetHandle(aHash, getter_AddRefs(handle));
ioMan->mHandles.GetHandle(aHash, false, getter_AddRefs(handle));
if (handle) {
nsRefPtr<nsILoadContextInfo> info =
CacheFileUtils::ParseKey(handle->Key(), &enhanceId, &uriSpec);
@@ -2605,7 +2615,7 @@ CacheFileIOManager::OverLimitEvictionInternal()
rv = CacheIndex::GetEntryForEviction(false, &hash, &cnt);
NS_ENSURE_SUCCESS(rv, rv);
rv = DoomFileByKeyInternal(&hash);
rv = DoomFileByKeyInternal(&hash, true);
if (NS_SUCCEEDED(rv)) {
consecutiveFailures = 0;
} else if (rv == NS_ERROR_NOT_AVAILABLE) {
@@ -2613,6 +2623,16 @@ CacheFileIOManager::OverLimitEvictionInternal()
"DoomFileByKeyInternal() failed. [rv=0x%08x]", rv));
// TODO index is outdated, start update
#ifdef DEBUG
// Dooming should never fail due to already doomed handle, but bug 1028415
// shows that this unexpected state can happen. Assert in debug build so
// we can find the cause if we ever find a way to reproduce it with NSPR
// logging enabled.
nsRefPtr<CacheFileHandle> handle;
mHandles.GetHandle(&hash, true, getter_AddRefs(handle));
MOZ_ASSERT(!handle || !handle->IsDoomed());
#endif
// Make sure index won't return the same entry again
CacheIndex::RemoveEntry(&hash);
consecutiveFailures = 0;
@@ -3630,7 +3650,7 @@ CacheFileIOManager::OpenNSPRHandle(CacheFileHandle *aHandle, bool aCreate)
rv = CacheIndex::GetEntryForEviction(true, &hash, &cnt);
if (NS_SUCCEEDED(rv)) {
rv = DoomFileByKeyInternal(&hash);
rv = DoomFileByKeyInternal(&hash, true);
}
if (NS_SUCCEEDED(rv)) {
rv = aHandle->mFile->OpenNSPRFileDesc(