From b14a145be67c45db4ed1d8fcfeccc61e59f46a49 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 26 Aug 2022 14:21:47 -0500 Subject: [PATCH] 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. --- dom/base/EventSource.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp index 35a7835cf4..06cabc3098 100644 --- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -1930,6 +1930,13 @@ EventSourceImpl::Dispatch(already_AddRefed 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 cancelable = do_QueryInterface(event_ref); + if (cancelable) { + cancelable->Cancel(); + } return NS_OK; } MOZ_ASSERT(mWorkerPrivate);