Bug 922123 - Shutdown hang with 100% CPU on Nightly with new cache, r=michal

This commit is contained in:
Honza Bambas 2013-10-02 11:30:42 +02:00
parent 333e3452e8
commit 331e760119
2 changed files with 21 additions and 14 deletions

View File

@ -76,11 +76,10 @@ CacheEntry::CacheEntry(const nsACString& aStorageID,
, mIsDoomed(false)
, mSecurityInfoLoaded(false)
, mPreventCallbacks(false)
, mIsRegistered(false)
, mIsRegistrationAllowed(true)
, mHasMainThreadOnlyCallback(false)
, mHasData(false)
, mState(NOTLOADED)
, mRegistration(NEVERREGISTERED)
, mWriter(nullptr)
, mPredictedDataSize(0)
, mDataSize(0)
@ -1169,24 +1168,27 @@ uint32_t CacheEntry::GetExpirationTime() const
bool CacheEntry::IsRegistered() const
{
MOZ_ASSERT(CacheStorageService::IsOnManagementThread());
return mIsRegistered;
return mRegistration == REGISTERED;
}
bool CacheEntry::CanRegister() const
{
MOZ_ASSERT(CacheStorageService::IsOnManagementThread());
return !mIsRegistered && mIsRegistrationAllowed;
return mRegistration == NEVERREGISTERED;
}
void CacheEntry::SetRegistered(bool aRegistered)
{
MOZ_ASSERT(CacheStorageService::IsOnManagementThread());
MOZ_ASSERT(mIsRegistrationAllowed);
mIsRegistered = aRegistered;
if (!aRegistered) // Never allow registration again
mIsRegistrationAllowed = false;
if (aRegistered) {
MOZ_ASSERT(mRegistration == NEVERREGISTERED);
mRegistration = REGISTERED;
}
else {
MOZ_ASSERT(mRegistration == REGISTERED);
mRegistration = DEREGISTERED;
}
}
bool CacheEntry::Purge(uint32_t aWhat)

View File

@ -232,11 +232,6 @@ private:
bool mSecurityInfoLoaded : 1;
// Prevents any callback invocation
bool mPreventCallbacks : 1;
// Accessed only on the management thread.
// Whether this entry is registered in the storage service helper arrays
bool mIsRegistered : 1;
// After deregistration entry is no allowed to register again
bool mIsRegistrationAllowed : 1;
// Way around when having a callback that cannot be invoked on non-main thread
bool mHasMainThreadOnlyCallback : 1;
// true: after load and an existing file, or after output stream has been opened.
@ -263,6 +258,16 @@ private:
// State of this entry.
EState mState;
enum ERegistration {
NEVERREGISTERED = 0, // The entry has never been registered
REGISTERED = 1, // The entry is stored in the memory pool index
DEREGISTERED = 2 // The entry has been removed from the pool
};
// Accessed only on the management thread. Records the state of registration
// this entry in the memory pool intermediate cache.
ERegistration mRegistration;
// If a new (empty) entry is requested to open an input stream before
// output stream has been opened, we must open output stream internally
// on CacheFile and hold until writer releases the entry or opens the output