Added mutex locks for modifying threads 'shutdown' flag and added check for exiting 'MySQL_Thread::run'

pull/3054/head
Javier Jaramago Fernández 6 years ago committed by René Cannaò
parent 9adfa6deba
commit 962177c1ee

@ -3609,14 +3609,20 @@ void MySQL_Threads_Handler::shutdown_threads() {
shutdown_=1;
if (mysql_threads) {
for (i=0; i<num_threads; i++) {
if (mysql_threads[i].worker)
if (mysql_threads[i].worker) {
pthread_mutex_lock(&mysql_threads[i].worker->thread_mutex);
mysql_threads[i].worker->shutdown=1;
pthread_mutex_unlock(&mysql_threads[i].worker->thread_mutex);
}
}
#ifdef IDLE_THREADS
if (GloVars.global.idle_threads) {
for (i=0; i<num_threads; i++) {
if (mysql_threads_idles[i].worker)
if (mysql_threads_idles[i].worker) {
pthread_mutex_lock(&mysql_threads[i].worker->thread_mutex);
mysql_threads_idles[i].worker->shutdown=1;
pthread_mutex_unlock(&mysql_threads[i].worker->thread_mutex);
}
}
}
#endif /* IDLE_THREADS */
@ -4145,6 +4151,7 @@ __run_skip_1a:
}
pthread_mutex_lock(&thread_mutex);
if (shutdown == 1) { return; }
mypolls.poll_timeout=0; // always reset this to 0 . If a session needs a specific timeout, it will set this one
curtime=monotonic_time();

Loading…
Cancel
Save