[network] Fix CacheEntry::mDoomCallback data race.
This commit is contained in:
1 file changed
+13
-3
@@ -481,7 +481,12 @@ NS_IMETHODIMP CacheEntry::OnFileReady(nsresult aResult, bool aIsNew)
|
||||
|
||||
NS_IMETHODIMP CacheEntry::OnFileDoomed(nsresult aResult)
|
||||
{
|
||||
if (mDoomCallback) {
|
||||
bool doomCallback = false;
|
||||
{
|
||||
mozilla::MutexAutoLock lock(mLock);
|
||||
doomCallback = bool(mDoomCallback);
|
||||
}
|
||||
if (doomCallback) {
|
||||
RefPtr<DoomCallbackRunnable> event =
|
||||
new DoomCallbackRunnable(this, aResult);
|
||||
NS_DispatchToMainThread(event);
|
||||
@@ -1738,8 +1743,13 @@ void CacheEntry::DoomFile()
|
||||
}
|
||||
}
|
||||
|
||||
// Always posts to the main thread.
|
||||
OnFileDoomed(rv);
|
||||
// mLock is already held in the caller; dispatch directly
|
||||
// instead of calling OnFileDoomed() which would deadlock when
|
||||
// re-acquiring the lock.
|
||||
if (mDoomCallback) {
|
||||
RefPtr<DoomCallbackRunnable> event = new DoomCallbackRunnable(this, rv);
|
||||
NS_DispatchToMainThread(event);
|
||||
}
|
||||
}
|
||||
|
||||
void CacheEntry::RemoveForcedValidity()
|
||||
|
||||
Reference in new issue
Block a user