bug 527871: fix shutdown assertion and leaking TestShellParent. still leaking ContentProcessParent's GeckoChildProcess, but needs discussion before fixing

This commit is contained in:
Chris Jones 2009-11-11 02:34:08 -06:00
parent 5629855e23
commit 0807e5c7e2
7 changed files with 34 additions and 14 deletions

View File

@ -95,6 +95,12 @@ ContentProcessParent::CreateTestShell()
return static_cast<TestShellParent*>(SendPTestShellConstructor());
}
bool
ContentProcessParent::DestroyTestShell(TestShellParent* aTestShell)
{
return SendPTestShellDestructor(aTestShell);
}
ContentProcessParent::ContentProcessParent()
: mMonitor("ContentProcessParent::mMonitor")
{

View File

@ -63,6 +63,7 @@ class ContentProcessParent : private PContentProcessParent,
{
private:
typedef mozilla::ipc::GeckoChildProcessHost GeckoChildProcessHost;
typedef mozilla::ipc::TestShellParent TestShellParent;
public:
static ContentProcessParent* GetSingleton();
@ -78,7 +79,9 @@ public:
virtual void OnWaitableEventSignaled(base::WaitableEvent *event);
TabParent* CreateTab();
mozilla::ipc::TestShellParent* CreateTestShell();
TestShellParent* CreateTestShell();
bool DestroyTestShell(TestShellParent* aTestShell);
private:
static ContentProcessParent* gSingleton;

View File

@ -106,21 +106,17 @@ AsyncChannel::Open(Transport* aTransport, MessageLoop* aIOLoop)
void
AsyncChannel::Close()
{
// XXXcjones pretty much stuck with this bad parent/child
// dichotomy as long as the child's IO thread is the "main"
// thread and we don't have proper shutdown handling implemented.
if (mChild)
return OnClose();
AssertWorkerThread();
MutexAutoLock lock(mMutex);
mIOLoop->PostTask(
FROM_HERE, NewRunnableMethod(this, &AsyncChannel::OnClose));
if (!mChild && ChannelConnected == mChannelState) {
AssertWorkerThread();
while (ChannelConnected == mChannelState)
mCvar.Wait();
mIOLoop->PostTask(
FROM_HERE, NewRunnableMethod(this, &AsyncChannel::OnClose));
while (ChannelConnected == mChannelState)
mCvar.Wait();
}
mTransport = NULL;
}

View File

@ -103,7 +103,7 @@ public:
virtual ~AsyncChannel()
{
if (mTransport)
if (!mChild && mTransport)
Close();
// we only hold a weak ref to the transport, which is "owned"
// by GeckoChildProcess/GeckoThread

View File

@ -1947,6 +1947,11 @@ main(int argc, char **argv)
JS_DestroyContext(cx);
} // this scopes the nsCOMPtrs
#ifdef MOZ_IPC
if (!XRE_ShutdownTestShell())
NS_ERROR("problem shutting down testshell");
#endif
#ifdef MOZ_CRASHREPORTER
// Get the crashreporter service while XPCOM is still active.
// This is a special exception: it will remain usable after NS_ShutdownXPCOM().

View File

@ -500,6 +500,14 @@ XRE_SendTestShellCommand(JSContext* aCx,
return true;
}
bool
XRE_ShutdownTestShell()
{
if (!gTestShellParent)
return true;
return ContentProcessParent::GetSingleton()->DestroyTestShell(gTestShellParent);
}
#endif // MOZ_IPC

View File

@ -490,5 +490,7 @@ XRE_API(bool,
XRE_SendTestShellCommand, (JSContext* aCx,
JSString* aCommand,
void* aCallback))
XRE_API(bool,
XRE_ShutdownTestShell, ())
#endif // _nsXULAppAPI_h__