Mrntt: Re-add exceptionInd
This now ensures that finalizeReq is indeed called from mrntt, since exception-experiencing threads will post an exceptionInd to mrntt, which will then call finalizeReq.
This commit is contained in:
@@ -106,9 +106,7 @@ void MindThread::main(MindThread& self)
|
||||
|
||||
if (sendExceptionInd)
|
||||
{
|
||||
mrntt::mrntt.finalizeReq(
|
||||
{nullptr, std::bind(
|
||||
&mrntt::marionetteFinalizeReqCb, std::placeholders::_1)});
|
||||
mrntt::mrntt.exceptionInd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,12 @@ public:
|
||||
typedef std::function<void(bool)> mrnttLifetimeMgmtOpCbFn;
|
||||
void initializeReq(Callback<mrnttLifetimeMgmtOpCbFn> callback);
|
||||
void finalizeReq(Callback<mrnttLifetimeMgmtOpCbFn> callback);
|
||||
// Intentionally doesn't take a callback.
|
||||
void exceptionInd();
|
||||
|
||||
private:
|
||||
class MrnttLifetimeMgmtOp;
|
||||
class TerminationEvent;
|
||||
};
|
||||
|
||||
extern std::atomic<int> exitCode;
|
||||
|
||||
@@ -117,6 +117,34 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class MarionetteComponent::TerminationEvent
|
||||
: public PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>
|
||||
{
|
||||
public:
|
||||
TerminationEvent(
|
||||
const std::shared_ptr<ComponentThread> &caller)
|
||||
: PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>(
|
||||
caller, {nullptr, nullptr})
|
||||
{}
|
||||
|
||||
public:
|
||||
void exceptionInd1_posted(
|
||||
[[maybe_unused]] std::shared_ptr<TerminationEvent> context
|
||||
)
|
||||
{
|
||||
auto self = ComponentThread::getSelf();
|
||||
if (self->id != ComponentThread::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
}
|
||||
|
||||
mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&mrntt::marionetteFinalizeReqCb,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
};
|
||||
|
||||
void MarionetteComponent::initializeReq(
|
||||
Callback<mrnttLifetimeMgmtOpCbFn> callback)
|
||||
{
|
||||
@@ -157,5 +185,19 @@ void MarionetteComponent::finalizeReq(
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void MarionetteComponent::exceptionInd()
|
||||
{
|
||||
auto faultyThread = ComponentThread::getSelf();
|
||||
auto mrntt = ComponentThread::getMrntt();
|
||||
|
||||
auto request = std::make_shared<TerminationEvent>(
|
||||
faultyThread);
|
||||
|
||||
mrntt->getIoService().post(
|
||||
STC(std::bind(
|
||||
&TerminationEvent::exceptionInd1_posted,
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
} // namespace mrntt
|
||||
} // namespace smo
|
||||
|
||||
@@ -184,9 +184,7 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
if (sendExceptionInd)
|
||||
{
|
||||
mrntt::exitCode = EXIT_FAILURE;
|
||||
mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&mrntt::marionetteFinalizeReqCb,
|
||||
std::placeholders::_1)});
|
||||
mrntt::mrntt.exceptionInd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user