bug 535867: fix threadsafety problem causing windows tinderbox error. r=trivial

This commit is contained in:
Chris Jones 2009-12-18 18:09:56 -06:00
parent a97f0b3ba3
commit d80073cd0a
3 changed files with 45 additions and 6 deletions

View File

@ -78,11 +78,14 @@ GeckoChildProcessHost::GeckoChildProcessHost(GeckoProcessType aProcessType,
}
GeckoChildProcessHost::~GeckoChildProcessHost()
{
MOZ_COUNT_DTOR(GeckoChildProcessHost);
if (mChildProcessHandle > 0)
ProcessWatcher::EnsureProcessTerminated(mChildProcessHandle);
{
AssertIOThread();
MOZ_COUNT_DTOR(GeckoChildProcessHost);
if (mChildProcessHandle > 0)
ProcessWatcher::EnsureProcessTerminated(mChildProcessHandle);
}
bool

View File

@ -43,6 +43,8 @@
#include "chrome/common/child_thread.h"
#include "nsDebug.h"
#include "mozilla/ipc/ScopedXREEmbed.h"
class NotificationService;
@ -50,6 +52,12 @@ class NotificationService;
namespace mozilla {
namespace ipc {
inline void AssertIOThread()
{
NS_ASSERTION(MessageLoop::TYPE_IO == MessageLoop::current()->type(),
"should be on the IO thread!");
}
class GeckoThread : public ChildThread
{
public:

View File

@ -1,8 +1,15 @@
#include "TestRPCErrorCleanup.h"
#include "mozilla/CondVar.h"
#include "mozilla/Mutex.h"
#include "IPDLUnitTests.h" // fail etc.
#include "IPDLUnitTestSubprocess.h"
using mozilla::CondVar;
using mozilla::Mutex;
using mozilla::MutexAutoLock;
namespace mozilla {
namespace _ipdltest {
@ -12,12 +19,33 @@ namespace _ipdltest {
// NB: this test does its own shutdown, rather than going through
// QuitParent(), because it's testing degenerate edge cases
void DeleteSubprocess(Mutex* mutex, CondVar* cvar)
{
MutexAutoLock lock(*mutex);
delete gSubprocess;
gSubprocess = NULL;
cvar->Notify();
}
void DeleteTheWorld()
{
delete static_cast<TestRPCErrorCleanupParent*>(gParentActor);
gParentActor = NULL;
delete gSubprocess;
gSubprocess = NULL;
// needs to be synchronous to avoid affecting event ordering on
// the main thread
Mutex mutex("TestRPCErrorCleanup.DeleteTheWorld.mutex");
CondVar cvar(mutex, "TestRPCErrorCleanup.DeleteTheWorld.cvar");
MutexAutoLock lock(mutex);
XRE_GetIOMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(DeleteSubprocess, &mutex, &cvar));
cvar.Wait();
}
void Done()