Bug 1401459 - always run HttpChannelChild::Release on main thread. r=mayhemer

--HG--
extra : rebase_source : 21705641833e1ad0cb0a3b45f8f0006d29246160
This commit is contained in:
Shih-Chiang Chien 2018-01-11 10:40:29 +08:00
parent f252fd08ea
commit b8abf494f9

View File

@ -245,6 +245,19 @@ NS_IMPL_ADDREF(HttpChannelChild)
NS_IMETHODIMP_(MozExternalRefCountType) HttpChannelChild::Release()
{
if (!NS_IsMainThread()) {
nsrefcnt count = mRefCnt;
nsresult rv = NS_DispatchToMainThread(
NewNonOwningRunnableMethod("HttpChannelChild::Release",
this,
&HttpChannelChild::Release));
// Continue Release procedure if failed to dispatch to main thread.
if (!NS_WARN_IF(NS_FAILED(rv))) {
return count - 1;
}
}
nsrefcnt count = --mRefCnt;
MOZ_ASSERT(int32_t(count) >= 0, "dup release");
NS_LOG_RELEASE(this, count, "HttpChannelChild");