Commit 88f49da8 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-34063 tpool - integer overflow in multiplication.

When calculating next wakeup timepoint for the timer thread, with large
thread_pool_stall_limit values, 32bit int overflow can happen.
Fixed by making one operand 8 byte large.

Also fixed the type of tick_interval to be unsigned, so it does not
go negative for very thread_pool_stall_limit.
parent b18259ec
......@@ -107,7 +107,7 @@ struct pool_timer_t
mysql_cond_t cond;
volatile uint64 current_microtime;
std::atomic<uint64_t> next_timeout_check;
int tick_interval;
uint tick_interval;
bool shutdown;
pthread_t timer_thread_id;
};
......@@ -577,7 +577,7 @@ static void* timer_thread(void *param)
struct timespec ts;
int err;
set_timespec_nsec(ts,timer->tick_interval*1000000);
set_timespec_nsec(ts, timer->tick_interval*1000000LL);
mysql_mutex_lock(&timer->mutex);
err= mysql_cond_timedwait(&timer->cond, &timer->mutex, &ts);
if (timer->shutdown)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment