diff --git a/implementations/Crafter.Debug-Session.cpp b/implementations/Crafter.Debug-Session.cpp index 14d206d..a3d4b35 100644 --- a/implementations/Crafter.Debug-Session.cpp +++ b/implementations/Crafter.Debug-Session.cpp @@ -595,13 +595,17 @@ namespace Crafter::Debug { const auto decoded = DecodeParams(params, *exchange); if (!decoded) return; Agent(decoded->force ? "quit --force" : "quit", Value()); - quitRequested.store(true); if (decoded->force) { + quitRequested.store(true); // From the thread the reply leaves on, so the main loop // need not run: --force is for an app whose loop is stuck. return exchange->ReplyThen(MakeReply(Object({ { "quitting", Value(true) }, { "force", Value(true) } })), [] { std::_Exit(0); }); } + // The reply before the flag: a loop that sees the flag may end + // the Session at once, and the transport delivers a reply given + // before its connections close, not one given after. exchange->Reply(MakeReply(Object({ { "quitting", Value(true) } }))); + quitRequested.store(true); } // ---- the Pump thread ----