mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 654926 - Hang in nsDiskCacheStreamIO::CloseOutputStream while downloading WebM video from YouTube. r=michal
This commit is contained in:
parent
0e734b3491
commit
22342d3341
30
netwerk/cache/nsCacheEntryDescriptor.cpp
vendored
30
netwerk/cache/nsCacheEntryDescriptor.cpp
vendored
@ -609,22 +609,34 @@ nsOutputStreamWrapper::LazyInit()
|
||||
nsCacheEntry* cacheEntry = mDescriptor->CacheEntry();
|
||||
if (!cacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
rv = nsCacheService::OpenOutputStreamForEntry(cacheEntry, mode, mStartOffset,
|
||||
getter_AddRefs(mOutput));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ASSERTION(mOutput == nsnull, "mOutput set in LazyInit");
|
||||
|
||||
mDescriptor->mOutput = mOutput;
|
||||
nsCOMPtr<nsIOutputStream> stream;
|
||||
rv = nsCacheService::OpenOutputStreamForEntry(cacheEntry, mode, mStartOffset,
|
||||
getter_AddRefs(stream));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCacheDevice* device = cacheEntry->CacheDevice();
|
||||
if (!device) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
// the entry has been truncated to mStartOffset bytes, inform the device.
|
||||
if (device) {
|
||||
// the entry has been truncated to mStartOffset bytes, inform device
|
||||
PRInt32 size = cacheEntry->DataSize();
|
||||
rv = device->OnDataSizeChange(cacheEntry, mStartOffset - size);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
cacheEntry->SetDataSize(mStartOffset);
|
||||
} else {
|
||||
rv = NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// If anything above failed, clean up internal state and get out of here
|
||||
// (see bug #654926)...
|
||||
if (NS_FAILED(rv)) {
|
||||
mDescriptor->InternalCleanup(stream);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// ... otherwise, set members and mark initialized
|
||||
mDescriptor->mOutput = mOutput = stream;
|
||||
mInitialized = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
19
netwerk/cache/nsCacheEntryDescriptor.h
vendored
19
netwerk/cache/nsCacheEntryDescriptor.h
vendored
@ -77,18 +77,21 @@ public:
|
||||
|
||||
void CloseOutput(void)
|
||||
{
|
||||
if (mOutput) {
|
||||
nsCOMPtr<nsIDiskCacheStreamInternal> tmp (do_QueryInterface(mOutput));
|
||||
if (tmp)
|
||||
tmp->CloseInternal();
|
||||
else
|
||||
mOutput->Close();
|
||||
|
||||
InternalCleanup(mOutput);
|
||||
mOutput = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void InternalCleanup(nsIOutputStream *stream)
|
||||
{
|
||||
if (stream) {
|
||||
nsCOMPtr<nsIDiskCacheStreamInternal> tmp (do_QueryInterface(stream));
|
||||
if (tmp)
|
||||
tmp->CloseInternal();
|
||||
else
|
||||
stream->Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
|
7
netwerk/cache/nsDiskCacheStreams.cpp
vendored
7
netwerk/cache/nsDiskCacheStreams.cpp
vendored
@ -484,8 +484,13 @@ nsDiskCacheStreamIO::Flush()
|
||||
CACHE_LOG_DEBUG(("CACHE: Flush [%x doomed=%u]\n",
|
||||
mBinding->mRecord.HashNumber(), mBinding->mDoomed));
|
||||
|
||||
if (!mBufDirty)
|
||||
if (!mBufDirty) {
|
||||
if (mFD) {
|
||||
(void) PR_Close(mFD);
|
||||
mFD = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// write data to cache blocks, or flush mBuffer to file
|
||||
nsDiskCacheMap *cacheMap = mDevice->CacheMap(); // get map reference
|
||||
|
Loading…
Reference in New Issue
Block a user