diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2016-03-09 10:19:09 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2016-03-09 10:19:09 +0100 |
commit | 351026ca535179abb956c5ad1e1d59aac0835254 (patch) | |
tree | 3ea50c4f9cfaa117abf3e3a6641a90424ea1ea45 /sql | |
parent | f12229f63ecbc12571d2333dfbc02c358e8ed817 (diff) | |
download | mariadb-git-351026ca535179abb956c5ad1e1d59aac0835254.tar.gz |
Fix threadpool memory leak and connect2 test
Diffstat (limited to 'sql')
-rw-r--r-- | sql/threadpool_common.cc | 8 | ||||
-rw-r--r-- | sql/threadpool_unix.cc | 1 | ||||
-rw-r--r-- | sql/threadpool_win.cc | 1 |
3 files changed, 9 insertions, 1 deletions
diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 7cba3f014f4..1653075a916 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -122,13 +122,19 @@ THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data) pthread_setspecific(THR_KEY_mysys, 0); my_thread_init(); st_my_thread_var* mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys); - DBUG_EXECUTE_IF("simulate_failed_connection_1", mysys_var= NULL; my_thread_end();); if (!mysys_var ||!(thd= connect->create_thd())) { /* Out of memory? */ connect->close_and_delete(); if (mysys_var) { +#ifdef HAVE_PSI_INTERFACE + /* + current PSI is still from worker thread. + Set to 0, to avoid premature cleanup by my_thread_end + */ + if (PSI_server) PSI_server->set_thread(0); +#endif my_thread_end(); } worker_context.restore(); diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc index 9f319e5c89a..91b392eb766 100644 --- a/sql/threadpool_unix.cc +++ b/sql/threadpool_unix.cc @@ -1235,6 +1235,7 @@ void tp_add_connection(CONNECT *connect) connection= alloc_connection(); if (!connection) { + connect->close_and_delete(); DBUG_VOID_RETURN; } connection->connect= connect; diff --git a/sql/threadpool_win.cc b/sql/threadpool_win.cc index c7cde5f6981..1281756f6bc 100644 --- a/sql/threadpool_win.cc +++ b/sql/threadpool_win.cc @@ -663,6 +663,7 @@ void tp_add_connection(CONNECT *connect) { connection_t *con; con= (connection_t *)malloc(sizeof(connection_t)); + DBUG_EXECUTE_IF("simulate_failed_connection_1", free(con);con= 0; ); if (!con) { tp_log_warning("Allocation failed", "tp_add_connection"); |