Backed out changeset f83eddcbebbc (bug 1170646) for bustage
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 07 Jul 2015 11:20:03 +0200
changeset 271789 e4e4f6e4f952b30de3c4a7bb11fea3613d68e36c
parent 271788 4fc6bd8ccab03ef526c8406e2a49f0bfc82fecd4
child 271790 18911ac1393404cc647b046dfe70c56cd2de3486
push id8304
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 19:25:01 +0000
treeherdermozilla-aurora@7308dd0a6c3b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1170646
milestone42.0a1
backs outf83eddcbebbc4c2c9554bb2a929f0f25bc6c563d
Backed out changeset f83eddcbebbc (bug 1170646) for bustage
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
-ssize_t
-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