MDEV-24084 Fix race between disconnect and KILL CONNECTION

Prior to this patch, it is possible to access freed memory
(THD::event_scheduler) from tp_post_kill_notification().

With this patch, memory is freed only when THD is no more accessible
from other threads, i.e after it is removed from the thread_list.
This commit is contained in:
Vladislav Vaintroub 2020-11-24 08:45:04 +01:00
parent 75e7132fca
commit 08b0b70daa

View file

@ -202,12 +202,11 @@ void tp_callback(TP_connection *c)
error:
c->thd= 0;
delete c;
if (thd)
{
threadpool_remove_connection(thd);
}
delete c;
worker_context.restore();
}