From bc1a522ee9571bacf22ca004a8fc0f3ee7cc56d4 Mon Sep 17 00:00:00 2001 From: John Schoenick Date: Fri, 28 Feb 2014 15:39:17 -0800 Subject: [PATCH] Bug 977955 - Cleanup PluginModule shutdown r=bsmedberg --- dom/plugins/ipc/PluginModuleParent.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 33648ca2f3a7..9fb0df7b2c75 100755 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -96,7 +96,7 @@ PluginModuleParent::LoadModule(const char* aFilePath) nsAutoPtr parent(new PluginModuleParent(aFilePath)); bool launched = parent->mSubprocess->Launch(prefSecs * 1000); if (!launched) { - // Need to set this so the destructor doesn't complain. + // We never reached open parent->mShutdown = true; return nullptr; } @@ -108,7 +108,7 @@ PluginModuleParent::LoadModule(const char* aFilePath) #ifdef MOZ_CRASHREPORTER // If this fails, we're having IPC troubles, and we're doomed anyways. if (!CrashReporterParent::CreateCrashReporter(parent.get())) { - parent->mShutdown = true; + parent->Close(); return nullptr; } #ifdef XP_WIN @@ -160,7 +160,9 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath) PluginModuleParent::~PluginModuleParent() { - NS_ASSERTION(OkToCleanup(), "unsafe destruction"); + if (!OkToCleanup()) { + NS_RUNTIMEABORT("unsafe destruction"); + } #ifdef MOZ_ENABLE_PROFILER_SPS ShutdownPluginProfiling(); @@ -171,6 +173,7 @@ PluginModuleParent::~PluginModuleParent() NPError err; NP_Shutdown(&err); } + NS_ASSERTION(mShutdown, "NP_Shutdown didn't"); if (mSubprocess) { @@ -228,7 +231,7 @@ PluginModuleParent::WriteExtraDataForMinidump(AnnotationTable& notes) pluginVersion = tag->mVersion; } } - + notes.Put(NS_LITERAL_CSTRING("PluginName"), pluginName); notes.Put(NS_LITERAL_CSTRING("PluginVersion"), pluginVersion); @@ -751,7 +754,7 @@ PluginModuleParent::ActorDestroy(ActorDestroyReason why) break; default: - NS_ERROR("Unexpected shutdown reason for toplevel actor."); + NS_RUNTIMEABORT("Unexpected shutdown reason for toplevel actor."); } } @@ -1194,11 +1197,11 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs uint32_t flags = 0; if (!CallNP_Initialize(flags, error)) { - mShutdown = true; + Close(); return NS_ERROR_FAILURE; } else if (*error != NPERR_NO_ERROR) { - mShutdown = true; + Close(); return NS_OK; } @@ -1225,11 +1228,11 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) #endif if (!CallNP_Initialize(flags, error)) { - mShutdown = true; + Close(); return NS_ERROR_FAILURE; } if (*error != NPERR_NO_ERROR) { - mShutdown = true; + Close(); return NS_OK; }