From 2c5067b6890974d0df335a833ed7a4e4c6ced183 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Tue, 7 Apr 2020 13:14:41 +0300 Subject: cleanup THR_KEY_mysys read TLS with my_thread_var write TLS with set_mysys_var() my_thread_var is no longer __attribute__ ((const)): this attribute is simply incorrect here. Read gcc manual for more information. sql/threadpool_generic.cc fails with that attribute. --- sql/threadpool_common.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'sql/threadpool_common.cc') diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 0a374147e07..b0438770aae 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -45,7 +45,6 @@ static void threadpool_remove_connection(THD *thd); static int threadpool_process_request(THD *thd); static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data); -extern "C" pthread_key(struct st_my_thread_var*, THR_KEY_mysys); extern bool do_command(THD*); static inline TP_connection *get_TP_connection(THD *thd) @@ -87,7 +86,7 @@ struct Worker_thread_context #ifdef HAVE_PSI_THREAD_INTERFACE psi_thread = PSI_THREAD_CALL(get_thread)(); #endif - mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys); + mysys_var= my_thread_var; } void restore() @@ -95,7 +94,7 @@ struct Worker_thread_context #ifdef HAVE_PSI_THREAD_INTERFACE PSI_THREAD_CALL(set_thread)(psi_thread); #endif - pthread_setspecific(THR_KEY_mysys,mysys_var); + set_mysys_var(mysys_var); pthread_setspecific(THR_THD, 0); } }; @@ -141,7 +140,7 @@ static inline void set_thd_idle(THD *thd) */ static void thread_attach(THD* thd) { - pthread_setspecific(THR_KEY_mysys,thd->mysys_var); + set_mysys_var(thd->mysys_var); thd->thread_stack=(char*)&thd; thd->store_globals(); #ifdef HAVE_PSI_THREAD_INTERFACE @@ -228,9 +227,9 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data) Store them in THD. */ - pthread_setspecific(THR_KEY_mysys, 0); + set_mysys_var(NULL); my_thread_init(); - st_my_thread_var* mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys); + st_my_thread_var* mysys_var= my_thread_var; if (!mysys_var ||!(thd= connect->create_thd(NULL))) { /* Out of memory? */ -- cgit v1.2.1