Bug 1395856 - add warning and assertion to detect intermittent failure; r?bagder
MozReview-Commit-ID: 1lZVLdHF2tC
--- a/netwerk/base/ProxyAutoConfig.cpp
+++ b/netwerk/base/ProxyAutoConfig.cpp
@@ -867,28 +867,30 @@ ProxyAutoConfig::GC()
JSAutoCompartment ac(mJSContext->Context(), mJSContext->Global());
JS_MaybeGC(mJSContext->Context());
}
ProxyAutoConfig::~ProxyAutoConfig()
{
MOZ_COUNT_DTOR(ProxyAutoConfig);
+ MOZ_ASSERT(mShutdown, "Shutdown must be called before dtor.");
NS_ASSERTION(!mJSContext,
"~ProxyAutoConfig leaking JS context that "
"should have been deleted on pac thread");
}
void
ProxyAutoConfig::Shutdown()
{
MOZ_ASSERT(!NS_IsMainThread(), "wrong thread for shutdown");
- if (GetRunning() || mShutdown)
+ if (NS_WARN_IF(GetRunning()) || mShutdown) {
return;
+ }
mShutdown = true;
delete mJSContext;
mJSContext = nullptr;
}
bool
ProxyAutoConfig::SrcAddress(const NetAddr *remoteAddress, nsCString &localAddress)
--- a/netwerk/base/nsPACMan.cpp
+++ b/netwerk/base/nsPACMan.cpp
@@ -343,16 +343,18 @@ nsPACMan::nsPACMan(nsIEventTarget *mainT
PR_NewThreadPrivateIndex(&sThreadLocalIndex, nullptr);
}
mPAC.SetThreadLocalIndex(sThreadLocalIndex);
mIncludePath = Preferences::GetBool(kPACIncludePath, false);
}
nsPACMan::~nsPACMan()
{
+ MOZ_ASSERT(mShutdown, "Shutdown must be called before dtor.");
+
if (mPACThread) {
if (NS_IsMainThread()) {
mPACThread->Shutdown();
}
else {
RefPtr<ShutdownThread> runnable = new ShutdownThread(mPACThread);
Dispatch(runnable.forget());
}
@@ -366,16 +368,18 @@ void
nsPACMan::Shutdown()
{
MOZ_ASSERT(NS_IsMainThread(), "pacman must be shutdown on main thread");
if (mShutdown) {
return;
}
mShutdown = true;
CancelExistingLoad();
+
+ MOZ_ASSERT(mPACThread, "mPAC requires mPACThread to shutdown");
PostCancelPendingQ(NS_ERROR_ABORT);
RefPtr<WaitForThreadShutdown> runnable = new WaitForThreadShutdown(this);
Dispatch(runnable.forget());
}
nsresult
nsPACMan::AsyncGetProxyForURI(nsIURI *uri,