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.
This commit is contained in:
parent
da7564edcf
commit
2c5067b689
@ -729,13 +729,14 @@ struct st_my_thread_var
|
||||
#endif
|
||||
};
|
||||
|
||||
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
|
||||
struct st_my_thread_var *_my_thread_var(void);
|
||||
extern void **my_thread_var_dbug(void);
|
||||
extern safe_mutex_t **my_thread_var_mutex_in_use(void);
|
||||
extern uint my_thread_end_wait_time;
|
||||
extern my_bool safe_mutex_deadlock_detector;
|
||||
#define my_thread_var (_my_thread_var())
|
||||
#define my_errno my_thread_var->thr_errno
|
||||
int set_mysys_var(struct st_my_thread_var *mysys_var);
|
||||
/*
|
||||
Keep track of shutdown,signal, and main threads so that my_end() will not
|
||||
report errors with them
|
||||
|
@ -141,7 +141,7 @@ void my_thread_global_reinit(void)
|
||||
my_thread_destroy_internal_mutex();
|
||||
my_thread_init_internal_mutex();
|
||||
|
||||
tmp= my_pthread_getspecific(struct st_my_thread_var*, THR_KEY_mysys);
|
||||
tmp= my_thread_var;
|
||||
DBUG_ASSERT(tmp);
|
||||
|
||||
my_thread_destory_thr_mutex(tmp);
|
||||
@ -279,7 +279,7 @@ my_bool my_thread_init(void)
|
||||
fprintf(stderr,"my_thread_init(): pthread_self: %p\n", pthread_self());
|
||||
#endif
|
||||
|
||||
if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys))
|
||||
if (my_thread_var)
|
||||
{
|
||||
#ifdef EXTRA_DEBUG_THREADS
|
||||
fprintf(stderr,"my_thread_init() called more than once in thread 0x%lx\n",
|
||||
@ -297,7 +297,7 @@ my_bool my_thread_init(void)
|
||||
error= 1;
|
||||
goto end;
|
||||
}
|
||||
pthread_setspecific(THR_KEY_mysys,tmp);
|
||||
set_mysys_var(tmp);
|
||||
tmp->pthread_self= pthread_self();
|
||||
my_thread_init_thr_mutex(tmp);
|
||||
|
||||
@ -334,7 +334,7 @@ end:
|
||||
void my_thread_end(void)
|
||||
{
|
||||
struct st_my_thread_var *tmp;
|
||||
tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
|
||||
tmp= my_thread_var;
|
||||
|
||||
#ifdef EXTRA_DEBUG_THREADS
|
||||
fprintf(stderr,"my_thread_end(): tmp: %p pthread_self: %p thread_id: %ld\n",
|
||||
@ -357,7 +357,7 @@ void my_thread_end(void)
|
||||
as the key is used by DBUG.
|
||||
*/
|
||||
DBUG_POP();
|
||||
pthread_setspecific(THR_KEY_mysys,0);
|
||||
set_mysys_var(NULL);
|
||||
|
||||
if (tmp && tmp->init)
|
||||
{
|
||||
@ -441,7 +441,7 @@ extern void **my_thread_var_dbug()
|
||||
struct st_my_thread_var *tmp;
|
||||
if (!my_thread_global_init_done)
|
||||
return NULL;
|
||||
tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
|
||||
tmp= my_thread_var;
|
||||
return tmp && tmp->init ? &tmp->dbug : 0;
|
||||
}
|
||||
#endif /* DBUG_OFF */
|
||||
@ -453,7 +453,7 @@ safe_mutex_t **my_thread_var_mutex_in_use()
|
||||
struct st_my_thread_var *tmp;
|
||||
if (!my_thread_global_init_done)
|
||||
return NULL;
|
||||
tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
|
||||
tmp= my_thread_var;
|
||||
return tmp ? &tmp->mutex_in_use : 0;
|
||||
}
|
||||
|
||||
|
@ -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? */
|
||||
|
Loading…
x
Reference in New Issue
Block a user