From 2cf2c3e7ea11e7686e23acfe2eb659082bcd9f7e Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Wed, 8 Dec 2010 14:38:26 -0800 Subject: [PATCH] Backout changeset 9ddbf8ab23a5 (bug 588873) to see if it caused bug 617048. --- xpcom/io/nsFastLoadFile.cpp | 94 +++++-------------------------------- xpcom/io/nsFastLoadFile.h | 7 --- 2 files changed, 11 insertions(+), 90 deletions(-) diff --git a/xpcom/io/nsFastLoadFile.cpp b/xpcom/io/nsFastLoadFile.cpp index bbed42c04f89..aaf7dcb279d2 100644 --- a/xpcom/io/nsFastLoadFile.cpp +++ b/xpcom/io/nsFastLoadFile.cpp @@ -61,23 +61,6 @@ #include #endif -#ifdef XP_WIN -#include -#include "private/pprio.h" // To get PR_ImportFile - -#define MOZ_WIN_MEM_TRY_BEGIN __try { -#define MOZ_WIN_MEM_TRY_CATCH(cmd) } \ - __except(GetExceptionCode()==EXCEPTION_IN_PAGE_ERROR ? \ - EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) \ - { \ - NS_WARNING("EXCEPTION_IN_PAGE_ERROR in " __FUNCTION__); \ - cmd; \ - } -#else -#define MOZ_WIN_MEM_TRY_BEGIN { -#define MOZ_WIN_MEM_TRY_CATCH(cmd) } -#endif - #ifdef DEBUG_brendan # define METERING # define DEBUG_MUX @@ -585,9 +568,7 @@ nsFastLoadFileReader::Read(char* aBuffer, PRUint32 aCount, PRUint32 *aBytesRead) return NS_BASE_STREAM_CLOSED; PRUint32 count = PR_MIN(mFileLen - mFilePos, aCount); -MOZ_WIN_MEM_TRY_BEGIN memcpy(aBuffer, mFileData+mFilePos, count); -MOZ_WIN_MEM_TRY_CATCH(return NS_ERROR_FAILURE) *aBytesRead = count; mFilePos += count; if (entry) { @@ -617,11 +598,9 @@ nsFastLoadFileReader::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure, PRUint32 count = PR_MIN(mFileLen - mFilePos, aCount); -MOZ_WIN_MEM_TRY_BEGIN // Errors returned from the writer get ignored. aWriter(this, aClosure, (char*)(mFileData + mFilePos), 0, count, aResult); -MOZ_WIN_MEM_TRY_CATCH(return NS_ERROR_FAILURE) mFilePos += count; if (entry) { NS_ASSERTION(entry->mBytesLeft >= *aResult, @@ -643,36 +622,10 @@ nsFastLoadFileReader::ComputeChecksum(PRUint32 *aResult) PRUint32 checksum = 0; // Skip first 2 fields. PRUint32 pos = offsetof(nsFastLoadHeader, mVersion); -#ifdef XP_WIN - if (pos != PR_Seek(mFD, pos, PR_SEEK_SET)) - return NS_ERROR_FAILURE; - PRUint32 len, rem = 0; - char buf[64 * 1024]; - while ((len = PR_Read(mFD, buf + rem, sizeof(buf) - rem)) && len > 0) { - len += rem; - rem = NS_AccumulateFastLoadChecksum(&checksum, - reinterpret_cast(buf), - len, - PR_FALSE); - if (rem) - memcpy(buf, buf + len - rem, rem); - } - if (len < 0) - return NS_ERROR_FAILURE; - - if (rem) { - NS_AccumulateFastLoadChecksum(&checksum, - reinterpret_cast(buf), - rem, - PR_TRUE); - } - -#else NS_AccumulateFastLoadChecksum(&checksum, mFileData + pos, mFileLen - pos, PR_TRUE); -#endif *aResult = checksum; return NS_OK; } @@ -910,27 +863,14 @@ nsresult nsFastLoadFileReader::Open() { nsresult rv; - PRFileDesc *fd; // OS file-descriptor - { -#ifdef XP_WIN - nsAutoString name; - rv = mFile->GetPath(name); - NS_ENSURE_SUCCESS(rv, rv); - // By not using OpenNSPRFileDesc can pass FILE_FLAG_SEQUENTIAL_SCAN so Windows reads in the file faster - HANDLE winFD = ::CreateFileW(name.get(), GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if (winFD == INVALID_HANDLE_VALUE) - return NS_ERROR_FAILURE; - fd = PR_ImportFile((PROsfd) winFD); -#else nsCOMPtr localFile = do_QueryInterface(mFile, &rv); if (NS_FAILED(rv)) return rv; + PRFileDesc *fd; // OS file-descriptor rv = localFile->OpenNSPRFileDesc(PR_RDONLY, 0, &fd); if (NS_FAILED(rv)) return rv; -#endif - } + PRInt64 size = PR_Available64(fd); if (size >= PR_INT32_MAX) { PR_Close(fd); @@ -950,12 +890,8 @@ nsFastLoadFileReader::Open() } mFileData = (PRUint8*) PR_MemMap(mFileMap, 0, mFileLen); -#ifdef XP_WIN - mFD = fd; -#else - // At this point the non-mmap file descriptor is no longer needed on non-windows + // At this point the non-mmap file descriptor is no longer needed PR_Close(fd); -#endif if (!mFileData) return NS_ERROR_FAILURE; @@ -964,7 +900,6 @@ nsFastLoadFileReader::Open() madvise((char *)mFileData, mFileLen, MADV_WILLNEED); #endif -MOZ_WIN_MEM_TRY_BEGIN rv = ReadHeader(&mHeader); if (NS_FAILED(rv)) return rv; @@ -973,22 +908,19 @@ MOZ_WIN_MEM_TRY_BEGIN rv = ComputeChecksum(&checksum); if (NS_FAILED(rv)) return rv; - + if (checksum != mHeader.mChecksum) return NS_ERROR_FAILURE; if (mHeader.mVersion != MFL_FILE_VERSION || - mHeader.mFooterOffset == 0 || + mHeader.mFooterOffset == 0 || memcmp(mHeader.mMagic, magic, MFL_FILE_MAGIC_SIZE)) return NS_ERROR_UNEXPECTED; - + SeekTo(mHeader.mFooterOffset); rv = ReadFooter(&mFooter); - -MOZ_WIN_MEM_TRY_CATCH(return NS_ERROR_FAILURE) - - if (NS_FAILED(rv)) + if (NS_FAILED(rv)) return rv; SeekTo(sizeof(nsFastLoadHeader)); @@ -1016,14 +948,10 @@ nsFastLoadFileReader::Close() PR_CloseFileMap(mFileMap); mFileMap = nsnull; } - -#ifdef XP_WIN - mFD = nsnull; -#endif mFileLen = 0; mFilePos = 0; - + if (!mFooter.mObjectMap) return NS_OK; @@ -1923,7 +1851,7 @@ nsresult nsFastLoadFileWriter::Open() { nsresult rv; - + if (!mSeekableOutput) return NS_ERROR_FAILURE; @@ -2008,7 +1936,7 @@ nsFastLoadFileWriter::Close() rv = mFileIO->GetInputStream(getter_AddRefs(input)); if (NS_FAILED(rv)) return rv; - + // Seek the input stream to right after checksum/magic. nsCOMPtr seekable = do_QueryInterface(input); rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, @@ -2230,7 +2158,7 @@ nsFastLoadFileWriter::WriteCompoundObject(nsISupports* aObject, { nsresult rv; nsCOMPtr rootObject(do_QueryInterface(aObject)); - + // We could assert that |rootObject != aObject|, but that would prevent // callers who don't know whether they're dealing with the primary // nsISupports pointer (e.g., they don't know which implementation of diff --git a/xpcom/io/nsFastLoadFile.h b/xpcom/io/nsFastLoadFile.h index d3459fe33bd3..85bcf68f4acf 100644 --- a/xpcom/io/nsFastLoadFile.h +++ b/xpcom/io/nsFastLoadFile.h @@ -56,7 +56,6 @@ #include "nsIFastLoadService.h" #include "nsISeekableStream.h" #include "nsISupportsArray.h" -#include "mozilla/FileUtils.h" /** * FastLoad file Object ID (OID) is an identifier for multiply and cyclicly @@ -401,12 +400,6 @@ class nsFastLoadFileReader PRUint32 mFilePos; // current position within file PRFileMap *mFileMap;// nspr datastructure for mmap PRUint8 *mFileData; // pointer to mmaped file -#ifdef XP_WIN - // Using a descriptor avoids having to check for EXCEPTION_IN_PAGE_ERROR - // in ComputeChecksum. Combined with FILE_FLAG_SEQUENTIAL_SCAN - // this speeds up cold IO via kernel readahead. - mozilla::AutoFDClose mFD; -#endif }; NS_COM nsresult