Issue #1990 - Part 6 - Fix for infinite loop from Release() on shutdown worker. If the worker is shut down, call Cancel() on the Runnable, this will prevent nsInputStreamReadyEvents to be called again when deallocated.

This commit is contained in:
Brian Smith 2022-08-26 14:21:47 -05:00 committed by roytam1
commit b14a145be6

View file

@ -1930,6 +1930,13 @@ EventSourceImpl::Dispatch(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags)
}
if (IsShutDown()) {
// If the worker is shut down, we don't want to leave this event hanging.
// If it is a cancelable we should call Cancel() to make sure it stops.
// That way we can safely return NS_OK to prevent shutdown error messages.
nsCOMPtr<nsICancelableRunnable> cancelable = do_QueryInterface(event_ref);
if (cancelable) {
cancelable->Cancel();
}
return NS_OK;
}
MOZ_ASSERT(mWorkerPrivate);