зеркало из https://github.com/mozilla/gecko-dev.git
Break self-cycle to fix leak (106860, r=dbaron, sr=bienvenu).
This commit is contained in:
Родитель
c39dde4d25
Коммит
8948a6287c
|
@ -2260,11 +2260,6 @@ nsFastLoadFileUpdater::Open(nsFastLoadFileReader* aReader)
|
|||
|
||||
// Map from reader dense, zero-based MFL_OID_TO_SHARP_INDEX(oid) to sharp
|
||||
// object offset and refcnt information in updater.
|
||||
PRUint32 saveReadOffset;
|
||||
rv = aReader->Tell(&saveReadOffset);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsFastLoadFileReader::nsObjectMapEntry* readObjectMap =
|
||||
aReader->mFooter.mObjectMap;
|
||||
for (i = 0, n = aReader->mFooter.mNumSharpObjects; i < n; i++) {
|
||||
|
@ -2292,10 +2287,6 @@ nsFastLoadFileUpdater::Open(nsFastLoadFileReader* aReader)
|
|||
readEntry);
|
||||
}
|
||||
|
||||
rv = aReader->Seek(nsISeekableStream::NS_SEEK_SET, saveReadOffset);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Copy URI spec string and initial segment offset in FastLoad file from
|
||||
// nsDocumentMapReadEntry in reader to mDocumentMapWriteEntry in updater.
|
||||
// If we didn't enumerate all entries, we ran out of memory.
|
||||
|
@ -2340,11 +2331,26 @@ nsFastLoadFileUpdater::Open(nsFastLoadFileReader* aReader)
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Avoid creating yet another object by implementing nsIFastLoadFileIO on
|
||||
// this updater, and save aReader's input stream so it can be returned by
|
||||
// GetInputStream called from nsFastLoadFileWriter::Close. This requires
|
||||
// that we override Close to break the resulting zero-length cycle.
|
||||
mFileIO = this;
|
||||
mInputStream = aReader->mInputStream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFastLoadFileUpdater::Close()
|
||||
{
|
||||
// Call base-class Close implementation, which uses mFileIO.
|
||||
nsresult rv = nsFastLoadFileWriter::Close();
|
||||
|
||||
// Break degenerate cycle from this->mFileIO to this.
|
||||
mFileIO = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewFastLoadFileUpdater(nsIObjectOutputStream* *aResult,
|
||||
nsIOutputStream* aOutputStream,
|
||||
|
|
|
@ -445,7 +445,7 @@ class NS_COM nsFastLoadFileWriter
|
|||
|
||||
nsresult Init();
|
||||
nsresult Open();
|
||||
NS_IMETHOD Close(void);
|
||||
NS_IMETHOD Close();
|
||||
|
||||
nsresult WriteObjectCommon(nsISupports* aObject,
|
||||
PRBool aIsStrongRef,
|
||||
|
@ -521,7 +521,8 @@ class NS_COM nsFastLoadFileUpdater
|
|||
// nsIFastLoadFileIO methods
|
||||
NS_DECL_NSIFASTLOADFILEIO
|
||||
|
||||
nsresult Open(nsFastLoadFileReader* aReader);
|
||||
nsresult Open(nsFastLoadFileReader* aReader);
|
||||
NS_IMETHOD Close();
|
||||
|
||||
static PLDHashOperator PR_CALLBACK
|
||||
CopyReadDocumentMapEntryToUpdater(PLDHashTable *aTable,
|
||||
|
|
Загрузка…
Ссылка в новой задаче