mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
bug 535867: fix threadsafety problem causing windows tinderbox error. r=trivial
This commit is contained in:
parent
a97f0b3ba3
commit
d80073cd0a
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user