Fix bug 97620 [r=rpotts, sr=brendan/ben] Added code to doom and clear

active cache entries when devices are shutdown.

Fix bug 88768 [a=nisheeth], fixing unary operator usage in nsCacheEntryDescriptor.cpp.
This commit is contained in:
gordon%netscape.com 2001-09-17 20:47:09 +00:00
parent d96999276d
commit a1c06d8a2a
3 changed files with 46 additions and 2 deletions

View File

@ -603,8 +603,8 @@ nsOutputStreamWrapper::Init()
if (!device) return NS_ERROR_NOT_AVAILABLE;
// the entry has been truncated to zero bytes, inform the device.
PRInt32 delta = -cacheEntry->DataSize();
rv = device->OnDataSizeChange(cacheEntry, delta);
PRInt32 delta = cacheEntry->DataSize();
rv = device->OnDataSizeChange(cacheEntry, -delta);
cacheEntry->SetDataSize(0);
}
return rv;

View File

@ -41,6 +41,7 @@
#include "nsIPref.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsVoidArray.h"
@ -1059,6 +1060,10 @@ nsCacheService::OnProfileShutdown(PRBool cleanse)
if (gService->mDiskDevice) {
if (cleanse)
gService->mDiskDevice->EvictEntries(nsnull);
gService->DoomActiveEntries();
gService->ClearDoomList();
gService->mDiskDevice->Shutdown();
gService->mEnableDiskDevice = PR_FALSE;
}
@ -1441,6 +1446,39 @@ nsCacheService::DeactivateAndClearEntry(PLDHashTable * table,
return PL_DHASH_REMOVE; // and continue enumerating
}
void
nsCacheService::DoomActiveEntries()
{
nsAutoVoidArray array;
PL_DHashTableEnumerate(&mActiveEntries.table, RemoveActiveEntry, &array);
PRUint32 count = array.Count();
for (PRUint32 i=0; i < count; ++i)
DoomEntry_Locked((nsCacheEntry *) array[i]);
}
PLDHashOperator PR_CALLBACK
nsCacheService::RemoveActiveEntry(PLDHashTable * table,
PLDHashEntryHdr * hdr,
PRUint32 number,
void * arg)
{
nsCacheEntry * entry = ((nsCacheEntryHashTableEntry *)hdr)->cacheEntry;
NS_ASSERTION(entry, "### active entry = nsnull!");
nsVoidArray * array = (nsVoidArray *) arg;
NS_ASSERTION(array, "### array = nsnull!");
array->AppendElement(entry);
// entry is being removed from the active entry list
entry->MarkInactive();
return PL_DHASH_REMOVE; // and continue enumerating
}
#if defined(PR_LOGGING)
void
nsCacheService::LogCacheStatistics()

View File

@ -159,12 +159,18 @@ private:
void ClearPendingRequests(nsCacheEntry * entry);
void ClearDoomList(void);
void ClearActiveEntries(void);
void DoomActiveEntries(void);
static
PLDHashOperator PR_CALLBACK DeactivateAndClearEntry(PLDHashTable * table,
PLDHashEntryHdr * hdr,
PRUint32 number,
void * arg);
static
PLDHashOperator PR_CALLBACK RemoveActiveEntry(PLDHashTable * table,
PLDHashEntryHdr * hdr,
PRUint32 number,
void * arg);
#if defined(PR_LOGGING)
void LogCacheStatistics();
#endif