diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 7dee7b204..50b06ca80 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -3252,7 +3252,8 @@ void MySQL_Threads_Handler::init(unsigned int num, size_t stack) { assert(rc==0); mysql_threads=(proxysql_mysql_thread_t *)calloc(num_threads,sizeof(proxysql_mysql_thread_t)); #ifdef IDLE_THREADS - mysql_threads_idles=(proxysql_mysql_thread_t *)calloc(num_threads,sizeof(proxysql_mysql_thread_t)); + if (GloVars.global.idle_threads) + mysql_threads_idles=(proxysql_mysql_thread_t *)calloc(num_threads,sizeof(proxysql_mysql_thread_t)); #endif // IDLE_THREADS } @@ -3264,9 +3265,11 @@ proxysql_mysql_thread_t * MySQL_Threads_Handler::create_thread(unsigned int tn, } #ifdef IDLE_THREADS } else { - if (pthread_create(&mysql_threads_idles[tn].thread_id, &attr, start_routine , &mysql_threads_idles[tn]) != 0) { - proxy_error("Thread creation\n"); - assert(0); + if (GloVars.global.idle_threads) { + if (pthread_create(&mysql_threads_idles[tn].thread_id, &attr, start_routine , &mysql_threads_idles[tn]) != 0) { + proxy_error("Thread creation\n"); + assert(0); + } } #endif // IDLE_THREADS } @@ -5550,7 +5553,7 @@ SQLite3_result * MySQL_Threads_Handler::SQL3_Processlist() { thr=(MySQL_Thread *)mysql_threads[i].worker; #ifdef IDLE_THREADS } else { - if (mysql_thread___session_idle_show_processlist && mysql_threads_idles) { + if (GloVars.global.idle_threads && mysql_thread___session_idle_show_processlist && mysql_threads_idles) { thr=(MySQL_Thread *)mysql_threads_idles[i-num_threads].worker; } #endif // IDLE_THREADS