Fixes #2919: Access to GloMTH from 'refresh_variables' and it's destruction is now mutex protected

pull/2957/head
Javier Jaramago Fernández 6 years ago
parent c415cb449f
commit 72ee8586ee

@ -92,6 +92,7 @@ class ProxySQL_GlobalVariables {
#ifdef PROXYSQLCLICKHOUSE
bool clickhouse_server;
#endif /* PROXYSQLCLICKHOUSE */
pthread_mutex_t ext_glomth_mutex;
} global;
struct mysql {
char *server_version;

@ -4731,6 +4731,7 @@ void MySQL_Thread::process_all_sessions() {
}
void MySQL_Thread::refresh_variables() {
pthread_mutex_lock(&GloVars.global.ext_glomth_mutex);
if (GloMTH==NULL) {
return;
}
@ -4910,6 +4911,7 @@ void MySQL_Thread::refresh_variables() {
mysql_thread___session_debug=(bool)GloMTH->get_variable_int((char *)"session_debug");
#endif /* DEBUG */
GloMTH->wrunlock();
pthread_mutex_unlock(&GloVars.global.ext_glomth_mutex);
}
MySQL_Thread::MySQL_Thread() {

@ -100,6 +100,7 @@ ProxySQL_GlobalVariables::ProxySQL_GlobalVariables() :
// global.use_proxysql_mem=false;
pthread_mutex_init(&global.start_mutex,NULL);
pthread_mutex_init(&checksum_mutex,NULL);
pthread_mutex_init(&global.ext_glomth_mutex,NULL);
epoch_version = 0;
checksums_values.updates_cnt = 0;
checksums_values.dumped_at = 0;

@ -1173,8 +1173,10 @@ void ProxySQL_Main_shutdown_all_modules() {
}
if (GloMTH) {
cpu_timer t;
pthread_mutex_lock(&GloVars.global.ext_glomth_mutex);
delete GloMTH;
GloMTH=NULL;
pthread_mutex_unlock(&GloVars.global.ext_glomth_mutex);
#ifdef DEBUG
std::cerr << "GloMTH shutdown in ";
#endif

Loading…
Cancel
Save