From baad2a9890b3e499a57f7a41165cd9cc8bc76e4d Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Sun, 14 Sep 2025 23:31:12 -0400 Subject: [PATCH] mrntt:main: Get rid of finalizeInd This leverages the new clean dynamic allocation of the globalMind object to make the mrntt::main and SMO's initialization and shutdown much cleaner. We no longer concern ourselves with shutting down the Mind threads inside of mrntt::main, but rather we leave that state machine to the Mind class and Mrntt component. --- smocore/marionette/main.cpp | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/smocore/marionette/main.cpp b/smocore/marionette/main.cpp index 47a1d48..3e643ae 100644 --- a/smocore/marionette/main.cpp +++ b/smocore/marionette/main.cpp @@ -70,12 +70,11 @@ void MarionetteThread::main(MarionetteThread& self) self.initializeTls(); mrntt::exitCode = EXIT_SUCCESS; static boost::asio::signal_set signals(self.getIoService(), SIGINT); - bool callFinalizeReq = false, callShutdownSalmanoff = false; + bool callShutdownSalmanoff = false; try { // Register SIGINT (Ctrl+C) and SIGSEGV handlers - signals.async_wait( - [&self](const boost::system::error_code& ec, int signal) + signals.async_wait([](const boost::system::error_code& ec, int signal) { if (ec) { return; } @@ -201,34 +200,17 @@ void MarionetteThread::main(MarionetteThread& self) } *out << outUsageMsg << e.what() << std::endl; - callFinalizeReq = true; } catch (const std::exception& e) { std::cerr << __func__ << ": Exception occurred: " << e.what() << std::endl; mrntt::exitCode = EXIT_FAILURE; - callShutdownSalmanoff = callFinalizeReq = true; } catch (...) { std::cerr << __func__ << ": Unknown exception occurred" << std::endl; mrntt::exitCode = EXIT_FAILURE; - callShutdownSalmanoff = callFinalizeReq = true; - } - - if (callFinalizeReq) - { -std::cout << __func__ << ": About call finalizeReq at end of mrnttMain." << '\n'; - mind::globalMind->finalizeReq([](bool success) - { - if (!success) { - std::cerr << "Failed to finalize Mind object (threads)" << '\n'; - } - mrntt::thread->getIoService().stop(); - }); - self.getIoService().reset(); - self.getIoService().run(); } if (callShutdownSalmanoff) {