MDEV-33978 P_S.THREADS is not showing all server threads

This patch only makes sure Linux getevents thread is shown in PS
This commit is contained in:
Vladislav Vaintroub 2024-12-23 15:58:55 +01:00
parent cc5d738999
commit a2f510fccf
5 changed files with 20 additions and 15 deletions

View file

@ -102,6 +102,7 @@ class aio_linux final : public aio
*/
constexpr unsigned MAX_EVENTS= 256;
aio->m_pool->m_worker_init_callback();
io_event events[MAX_EVENTS];
for (;;)
{
@ -110,14 +111,14 @@ class aio_linux final : public aio
continue;
case -EINVAL:
if (shutdown_in_progress)
return;
goto end;
/* fall through */
default:
if (ret < 0)
{
fprintf(stderr, "io_getevents returned %d\n", ret);
abort();
return;
goto end;
}
for (int i= 0; i < ret; i++)
{
@ -142,6 +143,8 @@ class aio_linux final : public aio
}
}
}
end:
aio->m_pool->m_worker_destroy_callback();
}
public:

View file

@ -92,7 +92,9 @@ public:
static void aio_completion_thread_proc(tpool_generic_win_aio* aio)
{
aio->m_pool->m_worker_init_callback();
aio->completion_thread_work();
aio->m_pool->m_worker_destroy_callback();
}
~tpool_generic_win_aio()

View file

@ -27,6 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 - 1301 USA*/
#define NOMINMAX
#endif
#include <windows.h>
#include <cassert>
/**
Windows-specific native file handle struct.
Apart from the actual handle, contains PTP_IO
@ -202,21 +204,24 @@ protected:
std::unique_ptr<aio> m_aio;
virtual aio *create_native_aio(int max_io)= 0;
public:
/**
Functions to be called at worker thread start/end
can be used for example to set some TLS variables
*/
void (*m_worker_init_callback)(void);
void (*m_worker_destroy_callback)(void);
void (*m_worker_init_callback)(void)= [] {};
void (*m_worker_destroy_callback)(void)= [] {};
public:
thread_pool() : m_aio(), m_worker_init_callback(), m_worker_destroy_callback()
thread_pool()
: m_aio()
{
}
virtual void submit_task(task *t)= 0;
virtual timer* create_timer(callback_func func, void *data=nullptr) = 0;
void set_thread_callbacks(void (*init)(), void (*destroy)())
{
assert(init);
assert(destroy);
m_worker_init_callback= init;
m_worker_destroy_callback= destroy;
}

View file

@ -571,8 +571,7 @@ void thread_pool_generic::worker_main(worker_data *thread_var)
{
task* task;
set_tls_pool(this);
if(m_worker_init_callback)
m_worker_init_callback();
m_worker_init_callback();
tls_worker_data = thread_var;
@ -581,8 +580,7 @@ void thread_pool_generic::worker_main(worker_data *thread_var)
task->execute();
}
if (m_worker_destroy_callback)
m_worker_destroy_callback();
m_worker_destroy_callback();
worker_end(thread_var);
}

View file

@ -45,9 +45,7 @@ class thread_pool_win : public thread_pool
if (!m_pool)
return;
if (m_pool->m_worker_destroy_callback)
m_pool->m_worker_destroy_callback();
m_pool->m_worker_destroy_callback();
m_pool->m_thread_count--;
}
/** This needs to be called before every IO or simple task callback.*/
@ -63,8 +61,7 @@ class thread_pool_win : public thread_pool
m_pool = pool;
m_pool->m_thread_count++;
// Call the thread init function.
if (m_pool->m_worker_init_callback)
m_pool->m_worker_init_callback();
m_pool->m_worker_init_callback();
}
};