bug 54470 Deleting orphaned entries (no record associated with them)

rather than holding them forever in memory on evict.
r=neeti sr=rpotts
(updating fix from branch 1.28.2.2 to tip)
This commit is contained in:
dp%netscape.com 2000-10-03 22:04:15 +00:00
Родитель 1c77698880
Коммит 1261ac6e1f
1 изменённых файлов: 14 добавлений и 6 удалений

20
netwerk/cache/mgr/nsCachedNetData.cpp поставляемый
Просмотреть файл

@ -1063,13 +1063,13 @@ nsCachedNetData::Delete(void)
// Truncate the content data for a cache entry, so as to make space in the // Truncate the content data for a cache entry, so as to make space in the
// cache for incoming data for another entry. // cache for incoming data for another entry.
//
// Deals with error case where the underlying recored is non-existent. In such
// a situation, we delete the entry.
nsresult nsresult
nsCachedNetData::Evict(PRUint32 aTruncatedContentLength) nsCachedNetData::Evict(PRUint32 aTruncatedContentLength)
{ {
nsCOMPtr<nsINetDataCacheRecord> record; nsresult rv = NS_ERROR_FAILURE;
nsresult rv = GetRecord(getter_AddRefs(record));
if ( NS_FAILED( rv ) ) return rv;
if ( record.get() == NULL ) return NS_ERROR_FAILURE;
// Tell observers about the eviction, so that they can release their // Tell observers about the eviction, so that they can release their
// references to this cache object. // references to this cache object.
Notify(nsIStreamAsFileObserver::REQUEST_DELETION, NS_OK); Notify(nsIStreamAsFileObserver::REQUEST_DELETION, NS_OK);
@ -1084,8 +1084,16 @@ nsCachedNetData::Evict(PRUint32 aTruncatedContentLength)
if (!GetFlag(ALLOW_PARTIAL)) if (!GetFlag(ALLOW_PARTIAL))
aTruncatedContentLength = 0; aTruncatedContentLength = 0;
nsresult rv = record->SetStoredContentLength(aTruncatedContentLength); // Tell the record about the eviction
if (NS_FAILED(rv)) return rv; nsCOMPtr<nsINetDataCacheRecord> record;
rv = GetRecord(getter_AddRefs(record));
if (NS_SUCCEEDED(rv) && record)
{
rv = record->SetStoredContentLength(aTruncatedContentLength);
if (NS_FAILED(rv))
return rv;
}
if (aTruncatedContentLength == 0) { if (aTruncatedContentLength == 0) {
SetFlag(VESTIGIAL); SetFlag(VESTIGIAL);