diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2016-05-12 16:29:17 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2016-06-01 16:43:22 +0400 |
commit | f7048e9a924784a81f5523bbed4a397b28b757de (patch) | |
tree | 7ee0c547f5f11ef221f3a8e533ce70a59bc07b4b /sql/table_cache.cc | |
parent | 286416404a2bba6c6312ae4a4527977002609c20 (diff) | |
download | mariadb-git-f7048e9a924784a81f5523bbed4a397b28b757de.tar.gz |
Move common code to a separate function
Diffstat (limited to 'sql/table_cache.cc')
-rw-r--r-- | sql/table_cache.cc | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/sql/table_cache.cc b/sql/table_cache.cc index b6c1e32b350..b75fa4adc59 100644 --- a/sql/table_cache.cc +++ b/sql/table_cache.cc @@ -152,6 +152,31 @@ static void tc_remove_table(TABLE *table) } +static void tc_remove_all_unused_tables(TDC_element *element, + TABLE_list *purge_tables, + bool mark_flushed) +{ + TABLE *table; + + element->wait_for_mdl_deadlock_detector(); + /* + Mark share flushed in order to ensure that it gets + automatically deleted once it is no longer referenced. + + Note that code in TABLE_SHARE::wait_for_old_version() assumes that + marking share flushed is followed by purge of unused table + shares. + */ + if (mark_flushed) + element->flushed= true; + while ((table= element->free_tables.pop_front())) + { + tc_remove_table(table); + purge_tables->push_front(table); + } +} + + /** Free all unused TABLE objects. @@ -176,17 +201,8 @@ struct tc_purge_arg static my_bool tc_purge_callback(TDC_element *element, tc_purge_arg *arg) { - TABLE *table; - mysql_mutex_lock(&element->LOCK_table_share); - element->wait_for_mdl_deadlock_detector(); - if (arg->mark_flushed) - element->flushed= true; - while ((table= element->free_tables.pop_front())) - { - tc_remove_table(table); - arg->purge_tables.push_front(table); - } + tc_remove_all_unused_tables(element, &arg->purge_tables, arg->mark_flushed); mysql_mutex_unlock(&element->LOCK_table_share); return FALSE; } @@ -880,23 +896,9 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, element->ref_count++; - element->wait_for_mdl_deadlock_detector(); - /* - Mark share flushed in order to ensure that it gets - automatically deleted once it is no longer referenced. + tc_remove_all_unused_tables(element, &purge_tables, + remove_type != TDC_RT_REMOVE_NOT_OWN_KEEP_SHARE); - Note that code in TABLE_SHARE::wait_for_old_version() assumes that - marking share flushed is followed by purge of unused table - shares. - */ - if (remove_type != TDC_RT_REMOVE_NOT_OWN_KEEP_SHARE) - element->flushed= true; - - while ((table= element->free_tables.pop_front())) - { - tc_remove_table(table); - purge_tables.push_front(table); - } if (kill_delayed_threads) kill_delayed_threads_for_table(element); |