From caa76249d88a8f4f88adc7f76980128bc73abe3e Mon Sep 17 00:00:00 2001 From: Dennis Felsing Date: Wed, 17 May 2023 01:04:06 +0200 Subject: [PATCH] Clean up CServerLogger (fixes #6598) --- src/engine/engine.h | 2 +- src/engine/server/main.cpp | 4 +++- src/engine/shared/engine.cpp | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/engine/engine.h b/src/engine/engine.h index 312b013f2..1f1c95957 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -36,7 +36,7 @@ public: virtual void Init() = 0; virtual void AddJob(std::shared_ptr pJob) = 0; - virtual void SetAdditionalLogger(std::unique_ptr &&pLogger) = 0; + virtual void SetAdditionalLogger(std::shared_ptr &&pLogger) = 0; static void RunJobBlocking(IJob *pJob); }; diff --git a/src/engine/server/main.cpp b/src/engine/server/main.cpp index 5462d7e71..5371b772d 100644 --- a/src/engine/server/main.cpp +++ b/src/engine/server/main.cpp @@ -182,7 +182,8 @@ int main(int argc, const char **argv) dbg_msg("server", "failed to open '%s' for logging", g_Config.m_Logfile); } } - pEngine->SetAdditionalLogger(std::make_unique(pServer)); + auto pServerLogger = std::make_shared(pServer); + pEngine->SetAdditionalLogger(pServerLogger); // run the server dbg_msg("server", "starting..."); @@ -191,6 +192,7 @@ int main(int argc, const char **argv) MysqlUninit(); secure_random_uninit(); + pServerLogger->OnServerDeletion(); // free delete pKernel; diff --git a/src/engine/shared/engine.cpp b/src/engine/shared/engine.cpp index 3b93fc5c0..c46dc9fac 100644 --- a/src/engine/shared/engine.cpp +++ b/src/engine/shared/engine.cpp @@ -30,7 +30,7 @@ public: IStorage *m_pStorage; bool m_Logging; - std::shared_ptr m_pFutureLogger; + std::shared_ptr m_pFutureLogger; char m_aAppName[256]; @@ -113,9 +113,9 @@ public: m_JobPool.Add(std::move(pJob)); } - void SetAdditionalLogger(std::unique_ptr &&pLogger) override + void SetAdditionalLogger(std::shared_ptr &&pLogger) override { - m_pFutureLogger->Set(std::move(pLogger)); + m_pFutureLogger = pLogger; } };