bug 525792: fix leaking PluginModules, call NP_Shutdown() on plugins. minor, no r=

This commit is contained in:
Chris Jones 2009-11-03 15:37:07 -06:00
parent b7375e8bd1
commit c916fbb575
10 changed files with 43 additions and 13 deletions

View File

@ -65,6 +65,9 @@ child:
rpc ~PPluginInstance()
returns (NPError rv);
rpc NP_Shutdown()
returns (NPError rv);
parent:
// XXX does NPN_UserAgent need to be RPC? certainly hope not, but to
// XXX be safe ...

View File

@ -141,6 +141,7 @@ PluginModuleChild::Init(const std::string& aPluginFilename,
memset((void*) &mFunctions, 0, sizeof(mFunctions));
mFunctions.size = sizeof(mFunctions);
// TODO: use PluginPRLibrary here
#if defined(OS_LINUX)
mShutdownFunc =
@ -184,10 +185,22 @@ PluginModuleChild::InitGraphics()
return true;
}
bool
PluginModuleChild::AnswerNP_Shutdown(NPError *rv)
{
AssertPluginThread();
// FIXME/cjones: should all instances be dead by now?
if (mShutdownFunc)
*rv = mShutdownFunc();
return true;
}
void
PluginModuleChild::CleanUp()
{
// FIXME/cjones: destroy all instances
}
bool

View File

@ -123,6 +123,8 @@ protected:
const nsTArray<nsCString>& aNames,
const nsTArray<nsCString>& aValues,
NPError* rv);
virtual bool
AnswerNP_Shutdown(NPError *rv);
public:
PluginModuleChild();

View File

@ -466,11 +466,12 @@ PluginModuleParent::NP_Shutdown(NPError* error)
{
_MOZ_LOG(__FUNCTION__);
// FIXME/cjones: shut down all our instances, and kill
// off the child process
// FIXME/cjones: should all sub-actors be dead by now?
*error = NPERR_NO_ERROR;
return NS_OK;
bool ok = CallNP_Shutdown(error);
Close();
return ok ? NS_OK : NS_ERROR_FAILURE;
}
nsresult

View File

@ -64,7 +64,7 @@ public:
~PluginProcessParent();
/**
* Asynchronously launch the plugin process.
* Synchronously launch the plugin process.
*/
bool Launch();

View File

@ -106,9 +106,12 @@ AsyncChannel::Open(Transport* aTransport, MessageLoop* aIOLoop)
void
AsyncChannel::Close()
{
// FIXME impl
mTransport->Close();
// don't lose error-state information
if (ChannelError != mChannelState)
mChannelState = ChannelClosed;
mTransport = NULL;
}
bool

View File

@ -105,6 +105,8 @@ public:
{
if (mTransport)
Close();
// we only hold a weak ref to the transport, which is "owned"
// by GeckoChildProcess/GeckoThread
mTransport = 0;
}
@ -115,8 +117,7 @@ public:
// i.e., mChannelState == ChannelConnected.
bool Open(Transport* aTransport, MessageLoop* aIOLoop=0);
// Close from the perspective of the RPC layer; leaves the
// underlying transport channel open, however.
// Close the underlying transport channel.
void Close();
// Asynchronously send a message to the other side of the channel

View File

@ -2200,6 +2200,7 @@ class _GenerateProtocolActorHeader(ipdl.ast.Visitor):
DestructorDecl(self.clsname, virtual=True))
dtor.addstmt(StmtExpr(ExprCall(ExprVar('MOZ_COUNT_DTOR'),
[ ExprVar(self.clsname) ])))
self.cls.addstmts([ dtor, Whitespace.NL ])
if p.decl.type.isToplevel():

View File

@ -357,6 +357,8 @@ nsNPAPIPlugin::~nsNPAPIPlugin()
{
// reset the callbacks list
memset((void*) &fCallbacks, 0, sizeof(fCallbacks));
delete fLibrary;
fLibrary = NULL;
}
@ -480,8 +482,10 @@ nsNPAPIPlugin::CreatePlugin(const char* aFilePath, PRLibrary* aLibrary,
#endif
#ifdef XP_OS2
PluginLibrary* pluginLib = GetNewPluginLibrary(aFilePath, aLibrary);
// create the new plugin handler
*aResult = new nsNPAPIPlugin(nsnull, aLibrary);
*aResult = new nsNPAPIPlugin(nsnull, pluginLib);
if (*aResult == NULL)
return NS_ERROR_OUT_OF_MEMORY;
@ -600,6 +604,8 @@ nsNPAPIPlugin::CreatePlugin(const char* aFilePath, PRLibrary* aLibrary,
// I just copied UNIX version.
// Makoto Hamanaka <VYA04230@nifty.com>
// XXX this code won't compile with the new e10s changes
nsNPAPIPlugin *plptr;
NPPluginFuncs callbacks;

View File

@ -80,7 +80,7 @@ private:
public:
nsNPAPIPlugin(NPPluginFuncs* callbacks,
PluginLibrary* aLibrary);
PluginLibrary* aLibrary /*assume ownership*/);
virtual ~nsNPAPIPlugin();
NS_DECL_ISUPPORTS