From 93eaaeb83da3557355cd25ca57c41d8ef4b91ba2 Mon Sep 17 00:00:00 2001 From: R Kent James Date: Fri, 2 Oct 2015 14:02:03 -0700 Subject: [PATCH] backout f600f0cd7bb3 (Bug 1170646) because of Thunderbird regressions with OSX, r=michal, a=sylvestre --HG-- extra : transplant_source : k%82%8EI%D0%1C%E1%60%8F%E9%3CA%22%AA%91j-%24%A6%15 --- netwerk/cache/nsDiskCacheBlockFile.cpp | 37 +++----------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/netwerk/cache/nsDiskCacheBlockFile.cpp b/netwerk/cache/nsDiskCacheBlockFile.cpp index 1ec99cf2d1d2..6a1f4182f24a 100644 --- a/netwerk/cache/nsDiskCacheBlockFile.cpp +++ b/netwerk/cache/nsDiskCacheBlockFile.cpp @@ -13,33 +13,6 @@ using namespace mozilla; -/* to cope with short read. - * xxx not sure if we want to repeat PR_Read() if no octet is ever read - * and is errno == EINTR - */ -static -PRInt32 -busy_beaver_PR_Read(PRFileDesc *fd, void * start, PRInt32 len) -{ - int n; - PRInt32 remaining = len; - - while (remaining > 0) { - n = PR_Read(fd, start, remaining); - if (n < 0) { - if( (len - remaining) == 0 ) // no octet is ever read - return -1; - break; - } else { - remaining -= n; - char *cp = (char *) start; - cp += n; - start = cp; - } - } - return len - remaining; -} - /****************************************************************************** * nsDiskCacheBlockFile - *****************************************************************************/ @@ -101,7 +74,7 @@ nsDiskCacheBlockFile::Open(nsIFile * blockFile, } else { // read the bit map - const int32_t bytesRead = busy_beaver_PR_Read(mFD, mBitMap, bitMapBytes); + const int32_t bytesRead = PR_Read(mFD, mBitMap, bitMapBytes); if ((bytesRead < 0) || ((uint32_t)bytesRead < bitMapBytes)) { *corruptInfo = nsDiskCache::kBlockFileBitMapReadError; rv = NS_ERROR_UNEXPECTED; @@ -280,15 +253,11 @@ nsDiskCacheBlockFile::ReadBlocks( void * buffer, if ((bytesToRead <= 0) || ((uint32_t)bytesToRead > mBlockSize * numBlocks)) { bytesToRead = mBlockSize * numBlocks; } - /* This has to tolerate short read, i.e., we need to repeat! */ - *bytesRead = busy_beaver_PR_Read(mFD, buffer, bytesToRead); - + *bytesRead = PR_Read(mFD, buffer, bytesToRead); + CACHE_LOG_DEBUG(("CACHE: nsDiskCacheBlockFile::Read [this=%p] " "returned %d / %d bytes", this, *bytesRead, bytesToRead)); - if(*bytesRead == -1) - return NS_ERROR_UNEXPECTED; - return NS_OK; }