зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1607224 - Data race on CacheFileHandle::mFileSize r=valentin
This patch fixes data race on CacheFileHandle::mFileSize when accessed on main thread by nsHttpChannel::ReportNetVSCacheTelemetry(). All other usages are on cache I/O thread. Differential Revision: https://phabricator.services.mozilla.com/D60407 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ca2c937269
Коммит
7c7d2abfab
|
@ -178,7 +178,7 @@ void CacheFileHandle::Log() {
|
|||
"pinning=%" PRIu32 ", fileExists=%d, fileSize=%" PRId64
|
||||
", leafName=%s, key=%s]",
|
||||
this, bool(mIsDoomed), bool(mPriority), bool(mClosed), bool(mInvalid),
|
||||
static_cast<uint32_t>(mPinning), bool(mFileExists), mFileSize,
|
||||
static_cast<uint32_t>(mPinning), bool(mFileExists), int64_t(mFileSize),
|
||||
leafName.get(), mKey.get()));
|
||||
} else {
|
||||
LOG(
|
||||
|
@ -189,7 +189,7 @@ void CacheFileHandle::Log() {
|
|||
", leafName=%s, key=%s]",
|
||||
this, LOGSHA1(mHash), bool(mIsDoomed), bool(mPriority), bool(mClosed),
|
||||
bool(mInvalid), static_cast<uint32_t>(mPinning), bool(mFileExists),
|
||||
mFileSize, leafName.get(), mKey.get()));
|
||||
int64_t(mFileSize), leafName.get(), mKey.get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1637,9 +1637,11 @@ nsresult CacheFileIOManager::OpenFileInternal(const SHA1Sum::Hash* aHash,
|
|||
MOZ_ASSERT(!handle->IsDoomed() && NS_SUCCEEDED(rv));
|
||||
}
|
||||
|
||||
rv = file->GetFileSize(&handle->mFileSize);
|
||||
int64_t fileSize = -1;
|
||||
rv = file->GetFileSize(&fileSize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
handle->mFileSize = fileSize;
|
||||
handle->mFileExists = true;
|
||||
|
||||
CacheIndex::EnsureEntryExists(aHash);
|
||||
|
@ -1735,9 +1737,11 @@ nsresult CacheFileIOManager::OpenSpecialFileInternal(
|
|||
mSpecialHandles.AppendElement(handle);
|
||||
|
||||
if (exists) {
|
||||
rv = file->GetFileSize(&handle->mFileSize);
|
||||
int64_t fileSize = -1;
|
||||
rv = file->GetFileSize(&fileSize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
handle->mFileSize = fileSize;
|
||||
handle->mFileExists = true;
|
||||
} else {
|
||||
handle->mFileSize = 0;
|
||||
|
|
|
@ -122,7 +122,10 @@ class CacheFileHandle final : public nsISupports {
|
|||
PinningStatus mPinning;
|
||||
|
||||
nsCOMPtr<nsIFile> mFile;
|
||||
int64_t mFileSize;
|
||||
|
||||
// file size is atomic because it is used on main thread by
|
||||
// nsHttpChannel::ReportNetVSCacheTelemetry()
|
||||
Atomic<int64_t, Relaxed> mFileSize;
|
||||
PRFileDesc* mFD; // if null then the file doesn't exists on the disk
|
||||
nsCString mKey;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче