Bug 1149842 - Release the mutex for NS_OpenAnonymousTemporaryFile to prevent the deadlock. r=roc

CLOSED TREE
This commit is contained in:
Benjamin Chen 2015-05-15 17:52:45 -04:00
Родитель d1ea9c0eda
Коммит 6009cf3ce8
1 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -20,9 +20,24 @@ EncodedBufferCache::AppendBuffer(nsTArray<uint8_t> & aBuf)
mEncodedBuffers.AppendElement()->SwapElements(aBuf);
if (!mTempFileEnabled && mDataSize > mMaxMemoryStorage) {
nsresult rv = NS_OpenAnonymousTemporaryFile(&mFD);
nsresult rv;
PRFileDesc* tempFD = nullptr;
{
// Release the mMutex because there is a sync dispatch to mainthread in
// NS_OpenAnonymousTemporaryFile.
MutexAutoUnlock unlock(mMutex);
rv = NS_OpenAnonymousTemporaryFile(&tempFD);
}
if (!NS_FAILED(rv)) {
mTempFileEnabled = true;
// Check the mDataSize again since we release the mMutex before.
if (mDataSize > mMaxMemoryStorage) {
mFD = tempFD;
mTempFileEnabled = true;
} else {
// Close the tempFD because the data had been taken during the
// MutexAutoUnlock.
PR_Close(tempFD);
}
}
}