[network] Fix CacheEntry::mDoomCallback data race.

This commit is contained in:
Moonchild committed 2026-07-27 14:32:51 +02:00
1 parent dd9099a7d3
commit 49d184e550
1 file changed
+13 -3
+13 -3
View File
@@ -481,7 +481,12 @@ NS_IMETHODIMP CacheEntry::OnFileReady(nsresult aResult, bool aIsNew)
NS_IMETHODIMP CacheEntry::OnFileDoomed(nsresult aResult) NS_IMETHODIMP CacheEntry::OnFileDoomed(nsresult aResult)
{ {
if (mDoomCallback) { bool doomCallback = false;
{
mozilla::MutexAutoLock lock(mLock);
doomCallback = bool(mDoomCallback);
}
if (doomCallback) {
RefPtr<DoomCallbackRunnable> event = RefPtr<DoomCallbackRunnable> event =
new DoomCallbackRunnable(this, aResult); new DoomCallbackRunnable(this, aResult);
NS_DispatchToMainThread(event); NS_DispatchToMainThread(event);
@@ -1738,8 +1743,13 @@ void CacheEntry::DoomFile()
} }
} }
// Always posts to the main thread. // mLock is already held in the caller; dispatch directly
OnFileDoomed(rv); // 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() void CacheEntry::RemoveForcedValidity()