Skip to content

Commit

Permalink
MDEV-24084 Fix race between disconnect and KILL CONNECTION
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vaintroub committed Nov 24, 2020
1 parent 75e7132 commit 08b0b70
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions sql/threadpool_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 08b0b70

Please sign in to comment.