Bug 73491 and bug 73513. Make the disk cache fail (more) gracefully. r=mcafee, sr=waterson.

This commit is contained in:
gordon%netscape.com 2001-03-27 23:56:18 +00:00
Родитель ef4876ed70
Коммит a61efb7b94
3 изменённых файлов: 8 добавлений и 4 удалений

6
netwerk/cache/src/nsDiskCacheDevice.cpp поставляемый
Просмотреть файл

@ -554,7 +554,7 @@ NS_IMETHODIMP nsDiskCacheEntryInfo::GetDataSize(PRUint32 *aDataSize)
static nsCOMPtr<nsIFileTransportService> gFileTransportService; static nsCOMPtr<nsIFileTransportService> gFileTransportService;
nsDiskCacheDevice::nsDiskCacheDevice() nsDiskCacheDevice::nsDiskCacheDevice()
: mCacheCapacity(0), mCacheSize(0) : mCacheCapacity(0), mCacheSize(0), mInitialized(PR_FALSE)
{ {
} }
@ -562,6 +562,7 @@ nsDiskCacheDevice::~nsDiskCacheDevice()
{ {
removeObservers(this); removeObservers(this);
if (mInitialized) {
#if 1 #if 1
// XXX implement poor man's eviction strategy right here, // XXX implement poor man's eviction strategy right here,
// keep deleting cache entries from oldest to newest, until // keep deleting cache entries from oldest to newest, until
@ -571,7 +572,7 @@ nsDiskCacheDevice::~nsDiskCacheDevice()
// XXX write out persistent information about the cache. // XXX write out persistent information about the cache.
writeCacheInfo(); writeCacheInfo();
}
// XXX release the reference to the cached file transport service. // XXX release the reference to the cached file transport service.
gFileTransportService = nsnull; gFileTransportService = nsnull;
} }
@ -598,6 +599,7 @@ nsDiskCacheDevice::Init()
scanDiskCacheEntries(getter_AddRefs(entries)); scanDiskCacheEntries(getter_AddRefs(entries));
} }
mInitialized = PR_TRUE;
return NS_OK; return NS_OK;
} }

1
netwerk/cache/src/nsDiskCacheDevice.h поставляемый
Просмотреть файл

@ -93,6 +93,7 @@ private:
nsDiskCacheEntryHashTable mBoundEntries; nsDiskCacheEntryHashTable mBoundEntries;
PRUint32 mCacheCapacity; PRUint32 mCacheCapacity;
PRUint32 mCacheSize; PRUint32 mCacheSize;
PRBool mInitialized;
}; };
#endif // _nsDiskCacheDevice_h_ #endif // _nsDiskCacheDevice_h_

5
netwerk/cache/src/nsDiskCacheEntry.cpp поставляемый
Просмотреть файл

@ -42,14 +42,15 @@ PLDHashTableOps nsDiskCacheEntryHashTable::ops =
}; };
nsDiskCacheEntryHashTable::nsDiskCacheEntryHashTable() nsDiskCacheEntryHashTable::nsDiskCacheEntryHashTable()
: initialized(0) : initialized(PR_FALSE)
{ {
} }
nsDiskCacheEntryHashTable::~nsDiskCacheEntryHashTable() nsDiskCacheEntryHashTable::~nsDiskCacheEntryHashTable()
{ {
PL_DHashTableFinish(&table); if (initialized)
PL_DHashTableFinish(&table);
} }