diff --git a/construct/console.cc b/construct/console.cc index b2d8d2146..990209a6a 100644 --- a/construct/console.cc +++ b/construct/console.cc @@ -71,6 +71,9 @@ construct::console::seen_message; decltype(construct::console::queue) construct::console::queue; +decltype(construct::console::quit_when_done) +construct::console::quit_when_done; + bool construct::console::spawn() { @@ -155,6 +158,9 @@ try if(!next_command()) break; + if(quit_when_done) + ircd::post{ircd::quit}; + return; } diff --git a/construct/console.h b/construct/console.h index 7bd3f2d2a..a857be5ca 100644 --- a/construct/console.h +++ b/construct/console.h @@ -19,6 +19,7 @@ struct construct::console static const ircd::string_view console_message; static std::once_flag seen_message; static std::deque queue; + static bool quit_when_done; std::string line; std::string record_path; diff --git a/construct/construct.cc b/construct/construct.cc index eb0900eb1..9d038adb0 100644 --- a/construct/construct.cc +++ b/construct/construct.cc @@ -178,17 +178,28 @@ noexcept try // The smoketest uses this ircd::run::level callback to set a flag when // each ircd::run::level is reached. All flags must be set to pass. The - // smoketest is inert unless the -smoketest program option is used. Note - // the special case for run::level::RUN, which initiates the transition - // to QUIT; the ircd::post allows any operations queued in the io_context - // to run in case the smoketest isn't the only callback being invoked. + // smoketest is inert unless the -smoketest program option is used. const ircd::run::changed smoketester { [](const auto &level) { smoketest.at(size_t(level) + 1) = true; - if(smoketest[0] && level == ircd::run::level::RUN) - ircd::post {[] { ircd::quit(); }}; + if(!smoketest[0]) + return; + + if(level != ircd::run::level::RUN) + return; + + if(construct::console::active()) + { + construct::console::quit_when_done = true; + return; + }; + + ircd::post + { + ircd::quit + }; } };