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;