Bug 910962 - Make DeallocShmem not assert when child has crashed (r=bsmedberg)

This commit is contained in:
Bill McCloskey 2014-01-31 10:43:44 -08:00
parent af4001ab84
commit 671c3d615a
4 changed files with 22 additions and 1 deletions

View File

@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
bug 960811 - clobber to rebuild preprocessed files when enabling synthetic APKs
Bug 925536 - Changing ipc/ipdl/ipdl/lower.py requires a clobber.

View File

@ -252,6 +252,13 @@ MessageChannel::Connected() const
return (ChannelOpening == mChannelState || ChannelConnected == mChannelState);
}
bool
MessageChannel::CanSend() const
{
MonitorAutoLock lock(*mMonitor);
return Connected();
}
void
MessageChannel::Clear()
{

View File

@ -94,6 +94,8 @@ class MessageChannel : HasResultCodes
// Make an Interrupt call to the other side of the channel
bool Call(Message* aMsg, Message* aReply);
bool CanSend() const;
void SetReplyTimeoutMs(int32_t aTimeoutMs);
bool IsOnCxxStack() const {

View File

@ -3706,6 +3706,10 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
# Message descriptor = UnShare(subprocess, mId, descriptor)
# mShmemMap.Remove(id)
# Shmem::Dealloc(rawmem)
# if (!mChannel.CanSend()) {
# delete descriptor;
# return true;
# }
# return descriptor && Send(descriptor)
destroyshmem.addstmts([
StmtDecl(Decl(_shmemIdType(), idvar.name),
@ -3716,8 +3720,14 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
failif = StmtIf(ExprNot(rawvar))
failif.addifstmt(StmtReturn.FALSE)
cansend = ExprCall(ExprSelect(p.channelVar(), '.', 'CanSend'), [])
returnif = StmtIf(ExprNot(cansend))
returnif.addifstmts([
StmtExpr(ExprDelete(descriptorvar)),
StmtReturn.TRUE])
destroyshmem.addstmts([
failif,
Whitespace.NL,
StmtDecl(Decl(Type('Message', ptr=1), descriptorvar.name),
init=_shmemUnshareFrom(
shmemvar,
@ -3727,6 +3737,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
StmtExpr(p.removeShmemId(idvar)),
StmtExpr(_shmemDealloc(rawvar)),
Whitespace.NL,
returnif,
Whitespace.NL,
StmtReturn(ExprBinary(
descriptorvar, '&&',
ExprCall(