From 5211c7ac9c4ba3c2704457b4353eb6f37b97c474 Mon Sep 17 00:00:00 2001 From: Tyler Karaszewski Date: Mon, 10 Jun 2024 14:58:03 -0700 Subject: [PATCH] Move shutdown logging to just before deleting the SQLitePool, which is where unmapping happens --- BedrockServer.cpp | 10 ++++++++++ main.cpp | 7 ------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/BedrockServer.cpp b/BedrockServer.cpp index 5a1de2175..e20853cae 100644 --- a/BedrockServer.cpp +++ b/BedrockServer.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -621,6 +622,15 @@ void BedrockServer::sync() // until they return. atomic_store(&_syncNode, shared_ptr(nullptr)); + // If we're not detaching, save that we're shutting down. + if (!_detach) { + ofstream file("/var/log/bedrock_shutdown", std::ios::app); + if (file) { + file << "shutdown " << getpid() << " " << SComposeTime("%Y-%m-%dT%H:%M:%S", STimeNow()) << endl; + file.close(); + } + } + // Release the current DB pool, and zero out our pointer. If any socket threads hold a handle to `_syncNode`, they will keep this in existence // until they release it. _dbPool = nullptr; diff --git a/main.cpp b/main.cpp index ff6ef35b4..56989a865 100644 --- a/main.cpp +++ b/main.cpp @@ -4,7 +4,6 @@ /// #include #include -#include #include #include #include @@ -401,12 +400,6 @@ int main(int argc, char* argv[]) { // All done SINFO("Graceful process shutdown complete"); - // Save that we're shutting down. - ofstream file("/var/log/bedrock_shutdown", std::ios::app); - if (file) { - file << "shutdown " << getpid() << " " << SComposeTime("%Y-%m-%dT%H:%M:%S", STimeNow()) << endl; - file.close(); - } return 0; }