summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2022-08-26 14:21:47 -0500
committerBrian Smith <brian@dbsoft.org>2022-08-26 14:21:47 -0500
commit860800629b179e2598801749080911607334e678 (patch)
tree105b7faf641a2381374ca68ce6df1a41083a952d
parentd6f18548a664b82489daeebf18fd3051f3edc8ac (diff)
downloaduxp-860800629b179e2598801749080911607334e678.tar.gz
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.
-rw-r--r--dom/base/EventSource.cpp7
1 files changed, 7 insertions, 0 deletions
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<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);