From 1a3db0e24f8e5be37a9aff2cce4681670f9de044 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 8 Mar 2016 10:28:26 +0100 Subject: Fix threadpool after it was broken by MDEV-6150 --- sql/threadpool_unix.cc | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'sql/threadpool_unix.cc') diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc index a43ae2162ae..9f319e5c89a 100644 --- a/sql/threadpool_unix.cc +++ b/sql/threadpool_unix.cc @@ -116,6 +116,7 @@ struct connection_t connection_t *next_in_queue; connection_t **prev_in_queue; ulonglong abs_wait_timeout; + CONNECT* connect; bool logged_in; bool bound_to_poll_descriptor; bool waiting; @@ -1215,6 +1216,7 @@ connection_t *alloc_connection() connection->logged_in= false; connection->bound_to_poll_descriptor= false; connection->abs_wait_timeout= ULONGLONG_MAX; + connection->thd= 0; } DBUG_RETURN(connection); } @@ -1228,26 +1230,19 @@ connection_t *alloc_connection() void tp_add_connection(CONNECT *connect) { connection_t *connection; - THD *thd; DBUG_ENTER("tp_add_connection"); - if (!(connection= alloc_connection()) || !(thd= connect->create_thd())) + connection= alloc_connection(); + if (!connection) { - my_free(connection); - connect->close_and_delete(); DBUG_VOID_RETURN; } - connection->thd= thd; - delete connect; - - add_to_active_threads(thd); + connection->connect= connect; - thd->event_scheduler.data= connection; - /* Assign connection to a group. */ thread_group_t *group= - &all_groups[thd->thread_id%group_count]; - + &all_groups[connect->thread_id%group_count]; + connection->thread_group=group; mysql_mutex_lock(&group->mutex); @@ -1271,9 +1266,12 @@ static void connection_abort(connection_t *connection) { DBUG_ENTER("connection_abort"); thread_group_t *group= connection->thread_group; - - threadpool_remove_connection(connection->thd); - + + if (connection->thd) + { + threadpool_remove_connection(connection->thd); + } + mysql_mutex_lock(&group->mutex); group->connection_count--; mysql_mutex_unlock(&group->mutex); @@ -1442,7 +1440,8 @@ static void handle_event(connection_t *connection) if (!connection->logged_in) { - err= threadpool_add_connection(connection->thd); + connection->thd = threadpool_add_connection(connection->connect, connection); + err= (connection->thd == NULL); connection->logged_in= true; } else -- cgit v1.2.1