diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-02-03 18:19:56 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-02-03 18:19:56 +0100 |
commit | bfe703a45888107936c184076eaead28b8b8a90a (patch) | |
tree | 183080fb1f6665badce232171ec4423927bbaec8 | |
parent | d0fb9580e0b2400d633b672e881a9d661cafb07f (diff) | |
download | mariadb-git-bfe703a45888107936c184076eaead28b8b8a90a.tar.gz |
don't let current_thd to point to a destroyed THD
* reset current_thd in THD::~THD, otherwise my_malloc_size_cb_func()
might access THD after it was destroyed.
* remove now redundant set_current_thd(0) calls that follow delete thd.
-rw-r--r-- | sql/events.cc | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 4 | ||||
-rw-r--r-- | sql/sql_acl.cc | 4 | ||||
-rw-r--r-- | sql/sql_base.cc | 1 | ||||
-rw-r--r-- | sql/sql_class.cc | 2 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 1 | ||||
-rw-r--r-- | sql/sql_reload.cc | 2 | ||||
-rw-r--r-- | sql/sql_servers.cc | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 | ||||
-rw-r--r-- | sql/sql_udf.cc | 2 | ||||
-rw-r--r-- | sql/tztime.cc | 4 |
11 files changed, 1 insertions, 25 deletions
diff --git a/sql/events.cc b/sql/events.cc index c4a7f63dbbc..7268686a33e 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -896,8 +896,6 @@ end: delete scheduler; } delete thd; - /* Remember that we don't have a THD */ - set_current_thd(0); DBUG_RETURN(res); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a94b696281b..423d07b02cd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2973,8 +2973,6 @@ bool one_thread_per_connection_end(THD *thd, bool put_in_cache) const bool wsrep_applier= IF_WSREP(thd->wsrep_applier, false); unlink_thd(thd); - /* Mark that current_thd is not valid anymore */ - set_current_thd(0); if (put_in_cache && cache_thread() && !wsrep_applier) DBUG_RETURN(0); // Thread is reused @@ -6555,7 +6553,6 @@ void handle_connections_sockets() (void) mysql_socket_close(new_sock); } delete thd; - set_current_thd(0); statistic_increment(connection_errors_internal, &LOCK_status); continue; } @@ -6670,7 +6667,6 @@ pthread_handler_t handle_connections_namedpipes(void *arg) { close_connection(thd, ER_OUT_OF_RESOURCES); delete thd; - set_current_thd(0); continue; } /* Host is unknown */ diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index c8714423933..96fff6d6763 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1140,8 +1140,6 @@ bool acl_init(bool dont_read_acl_tables) */ return_val= acl_reload(thd); delete thd; - /* Remember that we don't have a THD */ - set_current_thd(0); DBUG_RETURN(return_val); } @@ -6556,8 +6554,6 @@ bool grant_init() thd->store_globals(); return_val= grant_reload(thd); delete thd; - /* Remember that we don't have a THD */ - set_current_thd(0); DBUG_RETURN(return_val); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 70529b207b1..a5d7881707c 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -9024,7 +9024,6 @@ my_bool mysql_rm_tmp_tables(void) my_dirend(dirp); } delete thd; - set_current_thd(0); DBUG_RETURN(0); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index aaff36767da..7e26c77afcd 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1712,7 +1712,7 @@ THD::~THD() DBUG_ASSERT(status_var.local_memory_used == 0); } - set_current_thd(orig_thd); + set_current_thd(orig_thd == this ? 0 : orig_thd); DBUG_VOID_RETURN; } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index e9a0f138212..900167c1fab 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1775,7 +1775,6 @@ static void plugin_load(MEM_ROOT *tmp_root) end: /* Remember that we don't have a THD */ delete new_thd; - set_current_thd(0); DBUG_VOID_RETURN; } diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index fe494c760dc..6fc0e0024af 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -98,8 +98,6 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, if (tmp_thd) { delete tmp_thd; - /* Remember that we don't have a THD */ - set_current_thd(0); thd= 0; } reset_mqh((LEX_USER *)NULL, TRUE); diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index 7f4d70a6b43..9b944662545 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -173,8 +173,6 @@ bool servers_init(bool dont_read_servers_table) */ return_val= servers_reload(thd); delete thd; - /* Remember that we don't have a THD */ - set_current_thd(0); end: DBUG_RETURN(return_val); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ef6252c496b..e9a1ae981dc 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1674,8 +1674,6 @@ void execute_ddl_log_recovery() global_ddl_log.recovery_phase= FALSE; mysql_mutex_unlock(&LOCK_gdl); delete thd; - /* Remember that we don't have a THD */ - set_current_thd(0); DBUG_VOID_RETURN; } diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 2354f120041..d266e8f6bc7 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -258,8 +258,6 @@ void udf_init() end: close_mysql_tables(new_thd); delete new_thd; - /* Remember that we don't have a THD */ - set_current_thd(0); DBUG_VOID_RETURN; } diff --git a/sql/tztime.cc b/sql/tztime.cc index 24e61588a06..1cb1f5a0d5c 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1803,11 +1803,7 @@ end: if (org_thd) org_thd->store_globals(); /* purecov: inspected */ else - { - /* Remember that we don't have a THD */ - set_current_thd(0); my_pthread_setspecific_ptr(THR_MALLOC, 0); - } default_tz= default_tz_name ? global_system_variables.time_zone : my_tz_SYSTEM; |