Less shared variables loads under the mutex

Part of MDEV-19515 - Improve connect speed
This commit is contained in:
Sergey Vojtovich 2019-05-15 23:23:27 +04:00
parent 8268fa881f
commit 218a68bbc5

View file

@ -2688,10 +2688,15 @@ static bool cache_thread(THD *thd)
_db_pop_(); _db_pop_();
#endif #endif
while (! wake_thread && ! kill_cached_threads) while (!wake_thread)
{ {
int error= mysql_cond_timedwait(&COND_thread_cache, &LOCK_thread_cache, int error= mysql_cond_timedwait(&COND_thread_cache, &LOCK_thread_cache,
&abstime); &abstime);
if (kill_cached_threads)
{
mysql_cond_signal(&COND_flush_thread_cache);
break;
}
if (error == ETIMEDOUT || error == ETIME) if (error == ETIMEDOUT || error == ETIME)
{ {
/* /*
@ -2703,14 +2708,9 @@ static bool cache_thread(THD *thd)
} }
} }
cached_thread_count--; cached_thread_count--;
if (kill_cached_threads) if (auto connect= thread_cache.get())
mysql_cond_signal(&COND_flush_thread_cache);
if (wake_thread)
{ {
CONNECT *connect;
wake_thread--; wake_thread--;
connect= thread_cache.get();
mysql_mutex_unlock(&LOCK_thread_cache); mysql_mutex_unlock(&LOCK_thread_cache);
if (!(connect->create_thd(thd))) if (!(connect->create_thd(thd)))