mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 08:12:05 +00:00
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:
parent
d96999276d
commit
a1c06d8a2a
4
netwerk/cache/src/nsCacheEntryDescriptor.cpp
vendored
4
netwerk/cache/src/nsCacheEntryDescriptor.cpp
vendored
@ -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;
|
||||
|
38
netwerk/cache/src/nsCacheService.cpp
vendored
38
netwerk/cache/src/nsCacheService.cpp
vendored
@ -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()
|
||||
|
6
netwerk/cache/src/nsCacheService.h
vendored
6
netwerk/cache/src/nsCacheService.h
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user