From 4dfd819c308c6630a65d6c4045e88ef54fff67d9 Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Mon, 7 Aug 2006 18:04:29 +0000 Subject: [PATCH] fixes bug 335909 "google search 'wiki cheese' and click first hit, results in blank page" r=biesi --- netwerk/protocol/http/src/nsHttpChannel.cpp | 32 ++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/netwerk/protocol/http/src/nsHttpChannel.cpp b/netwerk/protocol/http/src/nsHttpChannel.cpp index 5d697061667..27d1f1de0bd 100644 --- a/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -127,21 +127,15 @@ nsHttpChannel::~nsHttpChannel() { LOG(("Destroying nsHttpChannel @%x\n", this)); - if (mResponseHead) { - delete mResponseHead; - mResponseHead = 0; - } - if (mCachedResponseHead) { - delete mCachedResponseHead; - mCachedResponseHead = 0; - } - NS_IF_RELEASE(mConnectionInfo); NS_IF_RELEASE(mTransaction); NS_IF_RELEASE(mProxyAuthContinuationState); NS_IF_RELEASE(mAuthContinuationState); + delete mResponseHead; + delete mCachedResponseHead; + // release our reference to the handler nsHttpHandler *handler = gHttpHandler; NS_RELEASE(handler); @@ -1669,10 +1663,22 @@ nsHttpChannel::CloseCacheEntry() LOG(("nsHttpChannel::CloseCacheEntry [this=%x]", this)); - // Doom the cache entry if it was newly created and never initialized. - // Else, we keep it around in the hope of being able to make use of it - // again (see CheckCache). - if (mCacheAccess == nsICache::ACCESS_WRITE && !mInitedCacheEntry) { + // If we have begun to create or replace a cache entry, and that cache + // entry is not complete and not resumable, then it needs to be doomed. + // Otherwise, CheckCache will make the mistake of thinking that the + // partial cache entry is complete. + + PRBool doom = PR_FALSE; + if (mInitedCacheEntry) { + NS_ASSERTION(mResponseHead, "oops"); + if (NS_FAILED(mStatus) && (mCacheAccess & nsICache::ACCESS_WRITE) && + !mResponseHead->IsResumable()) + doom = PR_TRUE; + } + else if (mCacheAccess == nsICache::ACCESS_WRITE) + doom = PR_TRUE; + + if (doom) { LOG((" dooming cache entry!!")); mCacheEntry->Doom(); }