From 2d7806c32531146d6280da4cc30c0915869be8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 9 May 2024 06:08:08 +0000 Subject: [PATCH] Moved run_SetAllSession_ToProcess0 to Base_Thread --- include/Base_Thread.h | 2 ++ include/MySQL_Thread.h | 4 ++-- include/PgSQL_Thread.h | 2 +- lib/Base_Thread.cpp | 19 +++++++++++++++++++ lib/MySQL_Thread.cpp | 20 +------------------- lib/PgSQL_Thread.cpp | 11 +---------- 6 files changed, 26 insertions(+), 32 deletions(-) diff --git a/include/Base_Thread.h b/include/Base_Thread.h index c41889d59..3ae475a76 100644 --- a/include/Base_Thread.h +++ b/include/Base_Thread.h @@ -42,6 +42,7 @@ class Base_Thread { public: unsigned long long curtime; unsigned long long last_move_to_idle_thread_time; + bool epoll_thread; int shutdown; PtrArray *mysql_sessions; Session_Regex **match_regexes; @@ -74,6 +75,7 @@ class Base_Thread { #endif // IDLE_THREADS template unsigned int find_session_idx_in_mysql_sessions(S * sess); template void ProcessAllMyDS_BeforePoll(); + template void run_SetAllSession_ToProcess0(); friend class MySQL_Thread; friend class PgSQL_Thread; diff --git a/include/MySQL_Thread.h b/include/MySQL_Thread.h index 83c824abd..b39e15de9 100644 --- a/include/MySQL_Thread.h +++ b/include/MySQL_Thread.h @@ -139,7 +139,7 @@ class __attribute__((aligned(64))) MySQL_Thread : public Base_Thread void run_BootstrapListener(); int run_ComputePollTimeout(); void run_StopListener(); - void run_SetAllSession_ToProcess0(); + //void run_SetAllSession_ToProcess0(); protected: @@ -170,7 +170,7 @@ class __attribute__((aligned(64))) MySQL_Thread : public Base_Thread // int shutdown; kill_queue_t kq; - bool epoll_thread; + //bool epoll_thread; bool poll_timeout_bool; // status variables are per thread only diff --git a/include/PgSQL_Thread.h b/include/PgSQL_Thread.h index f05b732a3..8ace70854 100644 --- a/include/PgSQL_Thread.h +++ b/include/PgSQL_Thread.h @@ -181,7 +181,7 @@ public: int pipefd[2]; kill_queue_t kq; - bool epoll_thread; + //bool epoll_thread; bool poll_timeout_bool; // status variables are per thread only diff --git a/lib/Base_Thread.cpp b/lib/Base_Thread.cpp index 0ce574166..b6f48e165 100644 --- a/lib/Base_Thread.cpp +++ b/lib/Base_Thread.cpp @@ -19,6 +19,8 @@ template void Base_Thread::ProcessAllMyDS_BeforePoll(); template void Base_Thread::ProcessAllMyDS_BeforePoll(); template void Base_Thread::register_session(MySQL_Thread*, MySQL_Session*, bool); template void Base_Thread::register_session(PgSQL_Thread*, PgSQL_Session*, bool); +template void Base_Thread::run_SetAllSession_ToProcess0(); +template void Base_Thread::run_SetAllSession_ToProcess0(); Base_Thread::Base_Thread() { }; @@ -468,3 +470,20 @@ void Base_Thread::ProcessAllMyDS_BeforePoll() { } } +template +void Base_Thread::run_SetAllSession_ToProcess0() { + T* thr = static_cast(this); + unsigned int n; +#ifdef IDLE_THREADS + // @note: in MySQL_Thread::run we have: bool idle_maintenance_thread=epoll_thread; + // Thus idle_maintenance_thread and epoll_thread are equivalent. + if (epoll_thread==false) { +#endif // IDLE_THREADS + for (n=0; nlen; n++) { + S *_sess=(S *)mysql_sessions->index(n); + _sess->to_process=0; + } +#ifdef IDLE_THREADS + } +#endif // IDLE_THREADS +} diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index a19069f6d..25e64f815 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -3140,24 +3140,6 @@ void MySQL_Thread::run_StopListener() { } } - -void MySQL_Thread::run_SetAllSession_ToProcess0() { - unsigned int n; -#ifdef IDLE_THREADS - // @note: in MySQL_Thread::run we have: bool idle_maintenance_thread=epoll_thread; - // Thus idle_maintenance_thread and epoll_thread are equivalent. - if (epoll_thread==false) { -#endif // IDLE_THREADS - for (n=0; nlen; n++) { - MySQL_Session *_sess=(MySQL_Session *)mysql_sessions->index(n); - _sess->to_process=0; - } -#ifdef IDLE_THREADS - } -#endif // IDLE_THREADS -} - - // main loop /** * @brief Main loop for the MySQL thread. @@ -3321,7 +3303,7 @@ __run_skip_1: refresh_variables(); } - run_SetAllSession_ToProcess0(); + run_SetAllSession_ToProcess0(); #ifdef IDLE_THREADS // here we handle epoll_wait() diff --git a/lib/PgSQL_Thread.cpp b/lib/PgSQL_Thread.cpp index efdbdbcbd..f26348b06 100644 --- a/lib/PgSQL_Thread.cpp +++ b/lib/PgSQL_Thread.cpp @@ -3081,16 +3081,7 @@ void PgSQL_Thread::run() { refresh_variables(); } -#ifdef IDLE_THREADS - if (idle_maintenance_thread == false) { -#endif // IDLE_THREADS - for (n = 0; n < mysql_sessions->len; n++) { - PgSQL_Session* _sess = (PgSQL_Session*)mysql_sessions->index(n); - _sess->to_process = 0; - } -#ifdef IDLE_THREADS - } -#endif // IDLE_THREADS + run_SetAllSession_ToProcess0(); #ifdef IDLE_THREADS // here we handle epoll_wait()