summaryrefslogtreecommitdiff
path: root/sql/threadpool_common.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2016-04-07 19:51:40 +0300
committerSergei Golubchik <serg@mariadb.org>2016-06-04 09:06:00 +0200
commit89685d55d7329065607df5a5f19b641e5947e22f (patch)
tree9c2f48944f77c71043b35ed1bc39555588be383c /sql/threadpool_common.cc
parent54f3e18f6e88bfae993749569104b4c89f0ea9ab (diff)
downloadmariadb-git-89685d55d7329065607df5a5f19b641e5947e22f.tar.gz
Reuse THD for new user connections
- To ensure that mallocs are marked for the correct THD, even if it's allocated in another thread, I added the thread_id to the THD constructor - Added st_my_thread_var to thr_lock_info_init() to avoid a call to my_thread_var - Moved things from THD::THD() to THD::init() - Moved some things to THD::cleanup() - Added THD::free_connection() and THD::reset_for_reuse() - Added THD to CONNECT::create_thd() - Added THD::thread_dbug_id and st_my_thread_var->dbug_id. These are needed to ensure that we have a constant thread_id used for debugging with a THD, even if it changes thread_id (=connection_id) - Set variables.pseudo_thread_id in constructor. Removed not needed sets.
Diffstat (limited to 'sql/threadpool_common.cc')
-rw-r--r--sql/threadpool_common.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc
index 2cfa3473222..520a16c467e 100644
--- a/sql/threadpool_common.cc
+++ b/sql/threadpool_common.cc
@@ -122,7 +122,7 @@ THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data)
pthread_setspecific(THR_KEY_mysys, 0);
my_thread_init();
st_my_thread_var* mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys);
- if (!mysys_var ||!(thd= connect->create_thd()))
+ if (!mysys_var ||!(thd= connect->create_thd(NULL)))
{
/* Out of memory? */
connect->close_and_delete();
@@ -200,6 +200,7 @@ void threadpool_remove_connection(THD *thd)
end_connection(thd);
close_connection(thd, 0);
unlink_thd(thd);
+ delete thd;
mysql_cond_broadcast(&COND_thread_count);
/*