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
This commit is contained in:
R Kent James 2015-10-02 14:02:03 -07:00
Родитель 2d27377591
Коммит 93eaaeb83d
1 изменённых файлов: 3 добавлений и 34 удалений

37
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;
}