| 975 | */ |
| 976 | |
| 977 | void tdc_release_share(TABLE_SHARE *share) |
| 978 | { |
| 979 | DBUG_ENTER("tdc_release_share"); |
| 980 | |
| 981 | mysql_mutex_lock(&share->tdc->LOCK_table_share); |
| 982 | DBUG_PRINT("enter", |
| 983 | ("share: %p table: %s.%s ref_count: %u", |
| 984 | share, share->db.str, share->table_name.str, |
| 985 | share->tdc->ref_count)); |
| 986 | DBUG_ASSERT(share->tdc->ref_count); |
| 987 | |
| 988 | if (share->tdc->ref_count > 1) |
| 989 | { |
| 990 | share->tdc->ref_count--; |
| 991 | if (!share->is_view) |
| 992 | mysql_cond_broadcast(&share->tdc->COND_release); |
| 993 | mysql_mutex_unlock(&share->tdc->LOCK_table_share); |
| 994 | DBUG_VOID_RETURN; |
| 995 | } |
| 996 | mysql_mutex_unlock(&share->tdc->LOCK_table_share); |
| 997 | |
| 998 | mysql_mutex_lock(&LOCK_unused_shares); |
| 999 | mysql_mutex_lock(&share->tdc->LOCK_table_share); |
| 1000 | if (--share->tdc->ref_count) |
| 1001 | { |
| 1002 | if (!share->is_view) |
| 1003 | mysql_cond_broadcast(&share->tdc->COND_release); |
| 1004 | mysql_mutex_unlock(&share->tdc->LOCK_table_share); |
| 1005 | mysql_mutex_unlock(&LOCK_unused_shares); |
| 1006 | DBUG_VOID_RETURN; |
| 1007 | } |
| 1008 | if (share->tdc->flushed || tdc_records() > tdc_size) |
| 1009 | { |
| 1010 | mysql_mutex_unlock(&LOCK_unused_shares); |
| 1011 | tdc_delete_share_from_hash(share->tdc); |
| 1012 | DBUG_VOID_RETURN; |
| 1013 | } |
| 1014 | /* Link share last in used_table_share list */ |
| 1015 | DBUG_PRINT("info", ("moving share to unused list")); |
| 1016 | DBUG_ASSERT(share->tdc->next == 0); |
| 1017 | unused_shares.push_back(share->tdc); |
| 1018 | mysql_mutex_unlock(&share->tdc->LOCK_table_share); |
| 1019 | mysql_mutex_unlock(&LOCK_unused_shares); |
| 1020 | DBUG_VOID_RETURN; |
| 1021 | } |
| 1022 | |
| 1023 | |
| 1024 | void tdc_remove_referenced_share(THD *thd, TABLE_SHARE *share) |
no test coverage detected