From fde27f3e02bd3464151520b192c9c56b7fb6c1f2 Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Wed, 8 Nov 2023 20:15:26 +0100 Subject: [PATCH] Increase max connections + join threads --- src/component/mysql.cpp | 12 ++++++++++++ src/component/mysql.hpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/component/mysql.cpp b/src/component/mysql.cpp index 89afe2f..ed50af1 100644 --- a/src/component/mysql.cpp +++ b/src/component/mysql.cpp @@ -161,6 +161,14 @@ namespace mysql class component final : public component_interface { public: + void pre_destroy() override + { + for (auto i = tasks.begin(); i != tasks.end(); ++i) + { + i->second.canceled = true; + } + } + void post_unpack() override { scripting::on_shutdown([]() @@ -168,6 +176,10 @@ namespace mysql for (auto i = tasks.begin(); i != tasks.end(); ++i) { i->second.canceled = true; + if (i->second.thread.joinable()) + { + i->second.thread.join(); + } } }); diff --git a/src/component/mysql.hpp b/src/component/mysql.hpp index b7e3a68..ac8d7fa 100644 --- a/src/component/mysql.hpp +++ b/src/component/mysql.hpp @@ -15,7 +15,7 @@ namespace sql = sqlpp::mysql; namespace mysql { - constexpr auto max_connections = 100; + constexpr auto max_connections = 256; constexpr auto connection_timeout = 200s; using database_mutex_t = std::recursive_mutex;