From a10324bb33bc5a8a91b0f6fefb4ce4d612d2997c Mon Sep 17 00:00:00 2001 From: Tyler Karaszewski Date: Tue, 9 Jul 2024 10:06:51 -0700 Subject: [PATCH] Close socket immediately for fire and forget commands --- BedrockServer.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/BedrockServer.cpp b/BedrockServer.cpp index 14397b327..ec26f5ea8 100644 --- a/BedrockServer.cpp +++ b/BedrockServer.cpp @@ -2139,14 +2139,12 @@ unique_ptr BedrockServer::buildCommandFromRequest(SData&& reques bool fireAndForget = false; if (SIEquals(request["Connection"], "forget") || (uint64_t)request.calc64("commandExecuteTime") > STimeNow()) { - // Respond immediately to make it clear we successfully queued it, but don't return the socket to indicate we - // don't need to respond. + // Respond immediately to make it clear we successfully queued it. We won't store the socket on the command. SINFO("Firing and forgetting '" << request.methodLine << "'"); SData response("202 Successfully queued"); - if (_shutdownState.load() != RUNNING) { - response["Connection"] = "close"; - } + response["Connection"] = "close"; socket.send(response.serialize()); + socket.shutdown(Socket::CLOSED); fireAndForget = true; // If we're shutting down, discard this command, we won't wait for the future.