From a44bd9d3e139c4ea7980f62a0ceeede69a54e1d5 Mon Sep 17 00:00:00 2001 From: Dennis Felsing Date: Thu, 17 Aug 2023 14:35:58 +0200 Subject: [PATCH] Shut down db connection pool (fixes #7036) --- src/engine/server/databases/connection_pool.cpp | 4 ++++ src/engine/server/databases/connection_pool.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/engine/server/databases/connection_pool.cpp b/src/engine/server/databases/connection_pool.cpp index 07e9b0efe..2ea2e3d9e 100644 --- a/src/engine/server/databases/connection_pool.cpp +++ b/src/engine/server/databases/connection_pool.cpp @@ -160,6 +160,9 @@ void CDbConnectionPool::ExecuteWrite( void CDbConnectionPool::OnShutdown() { + if(m_Shutdown) + return; + m_Shutdown = true; m_pShared->m_Shutdown.store(true); m_pShared->m_NumBackup.Signal(); int i = 0; @@ -470,6 +473,7 @@ CDbConnectionPool::CDbConnectionPool() CDbConnectionPool::~CDbConnectionPool() { + OnShutdown(); if(m_pWorkerThread) thread_wait(m_pWorkerThread); if(m_pBackupThread) diff --git a/src/engine/server/databases/connection_pool.h b/src/engine/server/databases/connection_pool.h index 040941118..87b7f2dc5 100644 --- a/src/engine/server/databases/connection_pool.h +++ b/src/engine/server/databases/connection_pool.h @@ -104,6 +104,8 @@ private: // where the next query is added to the queue. int m_InsertIdx = 0; + bool m_Shutdown = false; + struct CSharedData { // Used as signal that shutdown is in progress from main thread to