Bug 1488260 Part 2 - Cleanly shutdown when message forwarding fails, r=mccr8.

--HG--
extra : rebase_source : ceb20246e2a6bc44e7141234f04f61d3ef74f381
This commit is contained in:
Brian Hackett 2018-09-03 08:09:01 -10:00
Родитель 4a3bf67bb5
Коммит dc537cbc89
1 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -147,6 +147,15 @@ struct MOZ_RAII AutoMarkMainThreadWaitingForIPDLReply
}
};
static void
BeginShutdown()
{
// If there is a channel error or anything that could result from the child
// crashing, cleanly shutdown this process so that we don't generate a
// separate minidump which masks the initial failure.
MainThreadMessageLoop()->PostTask(NewRunnableFunction("Shutdown", Shutdown));
}
class MiddlemanProtocol : public ipc::IToplevelProtocol
{
public:
@ -172,7 +181,8 @@ public:
IPC::StringFromIPCMessageType(aMessage->type()),
(int) aMessage->routing_id());
if (!aProtocol->GetIPCChannel()->Send(aMessage)) {
MOZ_CRASH("MiddlemanProtocol::ForwardMessageAsync");
MOZ_RELEASE_ASSERT(aProtocol->mSide == ipc::ParentSide);
BeginShutdown();
}
} else {
delete aMessage;
@ -209,7 +219,8 @@ public:
MOZ_RELEASE_ASSERT(!*aReply);
Message* nReply = new Message();
if (!aProtocol->GetIPCChannel()->Send(aMessage, nReply)) {
MOZ_CRASH("MiddlemanProtocol::ForwardMessageSync");
MOZ_RELEASE_ASSERT(aProtocol->mSide == ipc::ParentSide);
BeginShutdown();
}
MonitorAutoLock lock(*gMonitor);
@ -245,7 +256,8 @@ public:
MOZ_RELEASE_ASSERT(!*aReply);
Message* nReply = new Message();
if (!aProtocol->GetIPCChannel()->Call(aMessage, nReply)) {
MOZ_CRASH("MiddlemanProtocol::ForwardCallMessage");
MOZ_RELEASE_ASSERT(aProtocol->mSide == ipc::ParentSide);
BeginShutdown();
}
MonitorAutoLock lock(*gMonitor);
@ -281,11 +293,11 @@ public:
virtual void OnChannelClose() override {
MOZ_RELEASE_ASSERT(mSide == ipc::ChildSide);
MainThreadMessageLoop()->PostTask(NewRunnableFunction("Shutdown", Shutdown));
BeginShutdown();
}
virtual void OnChannelError() override {
MainThreadMessageLoop()->PostTask(NewRunnableFunction("Shutdown", Shutdown));
BeginShutdown();
}
};