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:
2025-11-23 03:27:18 -04:00
parent 3747dee8a7
commit 2c891bd2f3
4 changed files with 47 additions and 6 deletions
+1 -3
View File
@@ -106,9 +106,7 @@ void MindThread::main(MindThread& self)
if (sendExceptionInd) if (sendExceptionInd)
{ {
mrntt::mrntt.finalizeReq( mrntt::mrntt.exceptionInd();
{nullptr, std::bind(
&mrntt::marionetteFinalizeReqCb, std::placeholders::_1)});
} }
} }
+3
View File
@@ -23,9 +23,12 @@ public:
typedef std::function<void(bool)> mrnttLifetimeMgmtOpCbFn; typedef std::function<void(bool)> mrnttLifetimeMgmtOpCbFn;
void initializeReq(Callback<mrnttLifetimeMgmtOpCbFn> callback); void initializeReq(Callback<mrnttLifetimeMgmtOpCbFn> callback);
void finalizeReq(Callback<mrnttLifetimeMgmtOpCbFn> callback); void finalizeReq(Callback<mrnttLifetimeMgmtOpCbFn> callback);
// Intentionally doesn't take a callback.
void exceptionInd();
private: private:
class MrnttLifetimeMgmtOp; class MrnttLifetimeMgmtOp;
class TerminationEvent;
}; };
extern std::atomic<int> exitCode; extern std::atomic<int> exitCode;
+42
View File
@@ -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( void MarionetteComponent::initializeReq(
Callback<mrnttLifetimeMgmtOpCbFn> callback) Callback<mrnttLifetimeMgmtOpCbFn> callback)
{ {
@@ -157,5 +185,19 @@ void MarionetteComponent::finalizeReq(
request.get(), request))); 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 mrntt
} // namespace smo } // namespace smo
+1 -3
View File
@@ -184,9 +184,7 @@ void MarionetteThread::main(MarionetteThread& self)
if (sendExceptionInd) if (sendExceptionInd)
{ {
mrntt::exitCode = EXIT_FAILURE; mrntt::exitCode = EXIT_FAILURE;
mrntt::mrntt.finalizeReq({nullptr, std::bind( mrntt::mrntt.exceptionInd();
&mrntt::marionetteFinalizeReqCb,
std::placeholders::_1)});
} }
} }