Add a callback for top-level actors to free themselves. (bug 1285364, r=billm)

--HG--
extra : rebase_source : 6954a2b34b521c886fba536cd7bedd5f30b94763
This commit is contained in:
David Anderson 2016-07-13 11:21:58 -07:00
Родитель 23ad7ef04f
Коммит 6b2b817ec9
2 изменённых файлов: 17 добавлений и 7 удалений

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

@ -2073,10 +2073,13 @@ MessageChannel::NotifyMaybeChannelError()
return; return;
} }
Clear();
// Oops, error! Let the listener know about it. // Oops, error! Let the listener know about it.
mChannelState = ChannelError; mChannelState = ChannelError;
// After this, the channel may be deleted.
mListener->OnChannelError(); mListener->OnChannelError();
Clear();
} }
void void
@ -2228,11 +2231,12 @@ MessageChannel::NotifyChannelClosed()
if (ChannelClosed != mChannelState) if (ChannelClosed != mChannelState)
NS_RUNTIMEABORT("channel should have been closed!"); NS_RUNTIMEABORT("channel should have been closed!");
// OK, the IO thread just closed the channel normally. Let the
// listener know about it.
mListener->OnChannelClose();
Clear(); Clear();
// OK, the IO thread just closed the channel normally. Let the
// listener know about it. After this point the channel may be
// deleted.
mListener->OnChannelClose();
} }
void void

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

@ -3243,6 +3243,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
destroysubtreevar = ExprVar('DestroySubtree') destroysubtreevar = ExprVar('DestroySubtree')
deallocsubtreevar = ExprVar('DeallocSubtree') deallocsubtreevar = ExprVar('DeallocSubtree')
deallocshmemvar = ExprVar('DeallocShmems') deallocshmemvar = ExprVar('DeallocShmems')
deallocselfvar = ExprVar('Dealloc' + _actorName(ptype.name(), self.side))
# OnProcesingError(code) # OnProcesingError(code)
codevar = ExprVar('aCode') codevar = ExprVar('aCode')
@ -3321,7 +3322,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
StmtExpr(ExprCall(destroysubtreevar, StmtExpr(ExprCall(destroysubtreevar,
args=[ _DestroyReason.NormalShutdown ])), args=[ _DestroyReason.NormalShutdown ])),
StmtExpr(ExprCall(deallocsubtreevar)), StmtExpr(ExprCall(deallocsubtreevar)),
StmtExpr(ExprCall(deallocshmemvar)) StmtExpr(ExprCall(deallocshmemvar)),
StmtExpr(ExprCall(deallocselfvar))
]) ])
else: else:
onclose.addstmt( onclose.addstmt(
@ -3335,7 +3337,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
StmtExpr(ExprCall(destroysubtreevar, StmtExpr(ExprCall(destroysubtreevar,
args=[ _DestroyReason.AbnormalShutdown ])), args=[ _DestroyReason.AbnormalShutdown ])),
StmtExpr(ExprCall(deallocsubtreevar)), StmtExpr(ExprCall(deallocsubtreevar)),
StmtExpr(ExprCall(deallocshmemvar)) StmtExpr(ExprCall(deallocshmemvar)),
StmtExpr(ExprCall(deallocselfvar))
]) ])
else: else:
onerror.addstmt( onerror.addstmt(
@ -3557,6 +3560,9 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
]) ])
self.cls.addstmts([ deallocshmem, Whitespace.NL ]) self.cls.addstmts([ deallocshmem, Whitespace.NL ])
deallocself = MethodDefn(MethodDecl(deallocselfvar.name, virtual=1))
self.cls.addstmts([ deallocself, Whitespace.NL ])
self.implementPickling() self.implementPickling()
## private members ## private members