summaryrefslogtreecommitdiff
path: root/mysys
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 /mysys
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 'mysys')
-rw-r--r--mysys/my_thr_init.c4
-rw-r--r--mysys/thr_lock.c7
2 files changed, 6 insertions, 5 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 1e4b85583b1..60a46997901 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -294,7 +294,7 @@ my_bool my_thread_init(void)
STACK_DIRECTION * (long)my_thread_stack_size;
mysql_mutex_lock(&THR_LOCK_threads);
- tmp->id= ++thread_id;
+ tmp->id= tmp->dbug_id= ++thread_id;
++THR_thread_count;
mysql_mutex_unlock(&THR_LOCK_threads);
tmp->init= 1;
@@ -400,7 +400,7 @@ my_thread_id my_thread_dbug_id()
my_thread_init().
*/
struct st_my_thread_var *tmp= my_thread_var;
- return tmp ? tmp->id : 0;
+ return tmp ? tmp->dbug_id : 0;
}
#ifdef DBUG_OFF
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index da653b12314..e8c4ed9c614 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -465,9 +465,10 @@ void thr_lock_delete(THR_LOCK *lock)
}
-void thr_lock_info_init(THR_LOCK_INFO *info)
+void thr_lock_info_init(THR_LOCK_INFO *info, struct st_my_thread_var *tmp)
{
- struct st_my_thread_var *tmp= my_thread_var;
+ if (tmp)
+ tmp= my_thread_var;
info->thread= tmp->pthread_self;
info->thread_id= tmp->id;
}
@@ -1816,7 +1817,7 @@ static void *test_thread(void *arg)
printf("Thread %s (%d) started\n",my_thread_name(),param); fflush(stdout);
- thr_lock_info_init(&lock_info);
+ thr_lock_info_init(&lock_info, 0);
for (i=0; i < lock_counts[param] ; i++)
thr_lock_data_init(locks+tests[param][i].lock_nr,data+i,NULL);
for (j=1 ; j < 10 ; j++) /* try locking 10 times */