diff --git a/include/proxysql_glovars.hpp b/include/proxysql_glovars.hpp index 097708c0b..6b8b299f4 100644 --- a/include/proxysql_glovars.hpp +++ b/include/proxysql_glovars.hpp @@ -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; diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index db10dd809..9db1fba7e 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -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() { diff --git a/lib/ProxySQL_GloVars.cpp b/lib/ProxySQL_GloVars.cpp index 44570d7ad..323e7949b 100644 --- a/lib/ProxySQL_GloVars.cpp +++ b/lib/ProxySQL_GloVars.cpp @@ -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; diff --git a/src/main.cpp b/src/main.cpp index 3cf2057b8..59c139831 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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