backout f600f0cd7bb3 (Bug 1170646) because of Thunderbird regressions with OSX, r=michal, a=sylvestre
authorR Kent James <rkent@caspia.com>
Fri, 02 Oct 2015 14:02:03 -0700
changeset 296284 ef920d4dd41c3e1554429fbe362d169d7592a291
parent 296283 35c9d4fa88063bab60bf49543382e4d70c937e9c
child 296285 ceadb2f312001085763d022231aa5d975cad0baa
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal, sylvestre
bugs1170646
milestone43.0a2
backs outf600f0cd7bb375615fa2a92ce24412095ae2c076
backout f600f0cd7bb3 (Bug 1170646) because of Thunderbird regressions with OSX, r=michal, a=sylvestre
netwerk/cache/nsDiskCacheBlockFile.cpp
--- a/netwerk/cache/nsDiskCacheBlockFile.cpp
+++ b/netwerk/cache/nsDiskCacheBlockFile.cpp
@@ -8,43 +8,16 @@
 #include "nsDiskCache.h"
 #include "nsDiskCacheBlockFile.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/MemoryReporting.h"
 #include <algorithm>
 
 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 - 
  *****************************************************************************/
 
 /******************************************************************************
  *  Open
  *****************************************************************************/
 nsresult
@@ -96,17 +69,17 @@ nsDiskCacheBlockFile::Open(nsIFile * blo
         
     } else if ((uint32_t)mFileSize < bitMapBytes) {
         *corruptInfo = nsDiskCache::kBlockFileSizeLessThanBitMap;
         rv = NS_ERROR_UNEXPECTED;  // XXX NS_ERROR_CACHE_INVALID;
         goto error_exit;
         
     } 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;
             goto error_exit;
         }
 #if defined(IS_LITTLE_ENDIAN)
         // Swap from network format
         for (unsigned int i = 0; i < mBitMapWords; ++i)
@@ -275,25 +248,21 @@ nsDiskCacheBlockFile::ReadBlocks( void *
     int32_t filePos = PR_Seek(mFD, blockPos, PR_SEEK_SET);
     if (filePos != blockPos)  return NS_ERROR_UNEXPECTED;
 
     // read the blocks
     int32_t bytesToRead = *bytesRead;
     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;
 }
 
 
 /******************************************************************************
  *  FlushBitMap
  *****************************************************************************/
 nsresult