mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Bug 1764119 - Part 2: Don't check gXPCOMThreadsShutdown in ThreadEventTarget::Dispatch, r=xpcom-reviewers,kmag,jstutte
We already have a mechanism for ending threads accepting new messages when they are shut down, so this only allows tasks started from thread shutdown tasks during xpcom shutdown to behave consistently. We already didn't prevent dispatching to the background thread pool at this time, so it should make little difference there as well, and may just instead save us from deadlocks where code expects a dispatch to succeed and it does not during actor shutdown. This patch both relaxes the check to only be a NS_ASSERTION, and relaxes it to allow dispatching to the current thread even after xpcom-shutdown-threads as that thread is definitely still alive. Differential Revision: https://phabricator.services.mozilla.com/D144592
This commit is contained in:
parent
41458369b2
commit
3065034574
@ -23,7 +23,12 @@ using namespace mozilla;
|
||||
|
||||
ThreadEventTarget::ThreadEventTarget(ThreadTargetSink* aSink,
|
||||
bool aIsMainThread)
|
||||
: mSink(aSink), mIsMainThread(aIsMainThread) {
|
||||
: mSink(aSink)
|
||||
#ifdef DEBUG
|
||||
,
|
||||
mIsMainThread(aIsMainThread)
|
||||
#endif
|
||||
{
|
||||
mThread = PR_GetCurrentThread();
|
||||
}
|
||||
|
||||
@ -52,10 +57,9 @@ ThreadEventTarget::Dispatch(already_AddRefed<nsIRunnable> aEvent,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (gXPCOMThreadsShutDown && !mIsMainThread) {
|
||||
NS_ASSERTION(false, "Failed Dispatch after xpcom-shutdown-threads");
|
||||
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
|
||||
}
|
||||
NS_ASSERTION(!gXPCOMThreadsShutDown || mIsMainThread ||
|
||||
PR_GetCurrentThread() == mThread,
|
||||
"Dispatch to non-main thread after xpcom-shutdown-threads");
|
||||
|
||||
LogRunnable::LogDispatch(event.get());
|
||||
|
||||
|
@ -47,7 +47,9 @@ class ThreadEventTarget final : public nsISerialEventTarget {
|
||||
~ThreadEventTarget();
|
||||
|
||||
RefPtr<ThreadTargetSink> mSink;
|
||||
#ifdef DEBUG
|
||||
bool mIsMainThread;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user