From c125f8fc6843dbba2f5ac5f6cbefa70f2bcb56e1 Mon Sep 17 00:00:00 2001 From: "fur%netscape.com" Date: Wed, 8 Dec 1999 03:32:56 +0000 Subject: [PATCH] + Handle the case of inability to write into cache correctly. + Be more aggressive about clearing the UPDATE_IN_PROGRESS flag on the cache entry git-svn-id: svn://10.0.0.236/trunk@55699 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/netwerk/cache/mgr/nsCachedNetData.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp b/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp index b0e259dd92f..80c4698c9c8 100644 --- a/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp +++ b/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp @@ -1064,6 +1064,9 @@ public: nsresult Init(PRUint32 aStartingOffset) { nsresult rv; + // Just in case the protocol handler forgot to set this flag... + mCacheEntry->SetFlag(nsCachedNetData::UPDATE_IN_PROGRESS); + rv = mCacheEntry->NewChannel(0, 0, getter_AddRefs(mChannel)); if (NS_FAILED(rv)) return rv; @@ -1083,7 +1086,7 @@ public: else mCacheEntry->ClearFlag(nsCachedNetData::TRUNCATED_CONTENT); mCacheEntry->ClearFlag(nsCachedNetData::VESTIGIAL); - + mCacheEntry->ClearFlag(nsCachedNetData::UPDATE_IN_PROGRESS); return mOriginalListener->OnStopRequest(channel, ctxt, status, errorMsg); } @@ -1109,7 +1112,11 @@ public: rv = mOriginalStream->Read(buf, count, aActualBytes); if (NS_FAILED(rv)) return rv; - write(buf, *aActualBytes); + rv = write(buf, *aActualBytes); + + // If the cache fills up, mark entry as partial content + if (NS_FAILED(rv)) + mCacheEntry->SetFlag(nsCachedNetData::TRUNCATED_CONTENT); return NS_OK; } @@ -1146,9 +1153,6 @@ nsCachedNetData::InterceptAsyncRead(nsIStreamListener *aOriginalListener, rv = interceptListener->Init(aStartingOffset); if (NS_FAILED(rv)) return rv; - // Just in case the protocol handler forgot to set this flag... - SetFlag(UPDATE_IN_PROGRESS); - NS_ADDREF(interceptListener); *aResult = interceptListener; return NS_OK;