From 80928395ccd5843cbb33c8ffa6e2d0f72928f87a Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Sun, 7 Jul 2024 15:12:11 +0000 Subject: [PATCH] Template for reset_all_backends() --- include/Base_Session.h | 1 + include/MySQL_Session.h | 2 +- include/PgSQL_Session.h | 2 +- lib/Base_Session.cpp | 23 +++++++++++++++++++++++ lib/MySQL_Session.cpp | 2 +- lib/PgSQL_Session.cpp | 2 +- 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/include/Base_Session.h b/include/Base_Session.h index fd6176bf7..92ef0f15f 100644 --- a/include/Base_Session.h +++ b/include/Base_Session.h @@ -112,6 +112,7 @@ class Base_Session { virtual void RequestEnd(DS *) = 0; virtual void SQLite3_to_MySQL(SQLite3_result*, char*, int, MySQL_Protocol*, bool in_transaction = false, bool deprecate_eof_active = false) = 0; bool has_any_backend(); + void reset_all_backends(); }; #endif // CLASS_BASE_SESSION_H diff --git a/include/MySQL_Session.h b/include/MySQL_Session.h index 6c878d662..6272e1375 100644 --- a/include/MySQL_Session.h +++ b/include/MySQL_Session.h @@ -416,7 +416,7 @@ class MySQL_Session: public Base_Session::has_any_backend(); template bool Base_Session::has_any_backend(); +template void Base_Session::reset_all_backends(); +template void Base_Session::reset_all_backends(); + template Base_Session::Base_Session() { }; @@ -347,3 +350,23 @@ bool Base_Session::has_any_backend() { } return false; } + + + + +/** + * @brief Reset all MySQL backends associated with this session. + * + * This function resets all MySQL backends associated with the current session. + * It iterates over all backends stored in the session, resets each backend, and then deletes it. + * + */ +template +void Base_Session::reset_all_backends() { + B *mybe; + while(mybes->len) { + mybe=(B *)mybes->remove_index_fast(0); + mybe->reset(); + delete mybe; + } +}; diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 6a486fcf4..435e15820 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -822,6 +822,7 @@ void MySQL_Session::update_expired_conns(const vectorlen) { @@ -741,7 +742,6 @@ void PgSQL_Session::reset_all_backends() { } }; -#if 0 void PgSQL_Session::writeout() { int tps = 10; // throttling per second , by default every 100ms int total_written = 0;