diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2018-09-25 16:06:32 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2018-10-05 09:29:22 +0100 |
commit | 8f329e8d37e08c28d4e39d5c87ea22300285d9cd (patch) | |
tree | 127f33d9649277bd515d61435f8cb4a193bd2b92 /sql/threadpool_win.cc | |
parent | 25ad38abe5b3fb6bb2aafff315de256b8f1e7839 (diff) | |
download | mariadb-git-8f329e8d37e08c28d4e39d5c87ea22300285d9cd.tar.gz |
MDEV-10384 Windows : Refactor threading in mysqld startup.
Remove threads that are doing nothing but wait
- main thread now handles the connections
(if threadpool is used, also threadpool threads would wait for connections)
- thread for socket and pipe connections are removed
- shutdown thread is now removed, we wait for shutdown
notification in main thread as well
- kill_server() is also called inside the main thread, after connection
loop finished.
Diffstat (limited to 'sql/threadpool_win.cc')
-rw-r--r-- | sql/threadpool_win.cc | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/sql/threadpool_win.cc b/sql/threadpool_win.cc index 3bc1ae3b371..67a8e783208 100644 --- a/sql/threadpool_win.cc +++ b/sql/threadpool_win.cc @@ -70,6 +70,11 @@ static DWORD fls; static bool skip_completion_port_on_success = false; +PTP_CALLBACK_ENVIRON get_threadpool_win_callback_environ() +{ + return pool? &callback_environ: 0; +} + /* Threadpool callbacks. @@ -134,7 +139,15 @@ struct TP_connection *new_TP_connection(CONNECT *connect) void TP_pool_win::add(TP_connection *c) { - SubmitThreadpoolWork(((TP_connection_win *)c)->work); + if(FlsGetValue(fls)) + { + /* Inside threadpool(), execute callback directly. */ + tp_callback(c); + } + else + { + SubmitThreadpoolWork(((TP_connection_win *)c)->work); + } } @@ -288,14 +301,13 @@ TP_connection_win::~TP_connection_win() void TP_connection_win::wait_begin(int type) { - /* Signal to the threadpool whenever callback can run long. Currently, binlog waits are a good candidate, its waits are really long */ if (type == THD_WAIT_BINLOG) { - if (!long_callback) + if (!long_callback && callback_instance) { CallbackMayRunLong(callback_instance); long_callback= true; @@ -308,12 +320,11 @@ void TP_connection_win::wait_end() /* Do we need to do anything ? */ } -/* - This function should be called first whenever a callback is invoked in the +/* + This function should be called first whenever a callback is invoked in the threadpool, does my_thread_init() if not yet done */ -extern ulong thread_created; -static void pre_callback(PVOID context, PTP_CALLBACK_INSTANCE instance) +void tp_win_callback_prolog() { if (FlsGetValue(fls) == NULL) { @@ -323,6 +334,12 @@ static void pre_callback(PVOID context, PTP_CALLBACK_INSTANCE instance) InterlockedIncrement((volatile long *)&tp_stats.num_worker_threads); my_thread_init(); } +} + +extern ulong thread_created; +static void pre_callback(PVOID context, PTP_CALLBACK_INSTANCE instance) +{ + tp_win_callback_prolog(); TP_connection_win *c = (TP_connection_win *)context; c->callback_instance = instance; c->long_callback = false; |