summaryrefslogtreecommitdiff
path: root/sql/threadpool_common.cc
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2015-12-04 18:16:04 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2015-12-04 18:16:04 +0100
commit50160216eab066de7a71dd8e355f0c5cb29c8789 (patch)
tree1fa9274cc7cbb63b6f275bbcc3c849828437e4f5 /sql/threadpool_common.cc
parentba8e630d97af2b2ed3e527070f1cab05571911fd (diff)
downloadmariadb-git-50160216eab066de7a71dd8e355f0c5cb29c8789.tar.gz
MDEV-9156 : Fix tp_add_connection()'s error handling
Avoid possible my_thread_end() in the main polling thread.
Diffstat (limited to 'sql/threadpool_common.cc')
-rw-r--r--sql/threadpool_common.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc
index 9e0cb07b86c..5bcea767aae 100644
--- a/sql/threadpool_common.cc
+++ b/sql/threadpool_common.cc
@@ -168,22 +168,28 @@ int threadpool_add_connection(THD *thd)
return retval;
}
+/*
+ threadpool_cleanup_connection() does the bulk of connection shutdown work.
+ Usually called from threadpool_remove_connection(), but rarely it might
+ be called also in the main polling thread if connection initialization fails.
+*/
+void threadpool_cleanup_connection(THD *thd)
+{
+ thd->net.reading_or_writing = 0;
+ end_connection(thd);
+ close_connection(thd, 0);
+ unlink_thd(thd);
+ mysql_cond_broadcast(&COND_thread_count);
+}
+
void threadpool_remove_connection(THD *thd)
{
-
Worker_thread_context worker_context;
worker_context.save();
-
thread_attach(thd);
- thd->net.reading_or_writing= 0;
-
- end_connection(thd);
- close_connection(thd, 0);
-
- unlink_thd(thd);
- mysql_cond_broadcast(&COND_thread_count);
+ threadpool_cleanup_connection(thd);
/*
Free resources associated with this connection:
mysys thread_var and PSI thread.