summaryrefslogtreecommitdiff
path: root/sql/threadpool_unix.cc
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2016-03-08 10:28:26 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2016-03-08 10:28:26 +0100
commit1a3db0e24f8e5be37a9aff2cce4681670f9de044 (patch)
tree3cdddc9d9857b1a97b200845b416613700855e65 /sql/threadpool_unix.cc
parenta8d97fb8186968e193ce0f3c8d1ee416b115e9e0 (diff)
downloadmariadb-git-1a3db0e24f8e5be37a9aff2cce4681670f9de044.tar.gz
Fix threadpool after it was broken by MDEV-6150
Diffstat (limited to 'sql/threadpool_unix.cc')
-rw-r--r--sql/threadpool_unix.cc31
1 files changed, 15 insertions, 16 deletions
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