| 688 | |
| 689 | |
| 690 | void tdc_purge(bool all) |
| 691 | { |
| 692 | DBUG_ENTER("tdc_purge"); |
| 693 | while (all || tdc_records() > tdc_size) |
| 694 | { |
| 695 | TDC_element *element; |
| 696 | |
| 697 | mysql_mutex_lock(&LOCK_unused_shares); |
| 698 | if (!(element= unused_shares.pop_front())) |
| 699 | { |
| 700 | mysql_mutex_unlock(&LOCK_unused_shares); |
| 701 | break; |
| 702 | } |
| 703 | |
| 704 | /* Concurrent thread may start using share again, reset prev and next. */ |
| 705 | element->prev= 0; |
| 706 | element->next= 0; |
| 707 | mysql_mutex_lock(&element->LOCK_table_share); |
| 708 | if (element->ref_count) |
| 709 | { |
| 710 | mysql_mutex_unlock(&element->LOCK_table_share); |
| 711 | mysql_mutex_unlock(&LOCK_unused_shares); |
| 712 | continue; |
| 713 | } |
| 714 | mysql_mutex_unlock(&LOCK_unused_shares); |
| 715 | |
| 716 | tdc_delete_share_from_hash(element); |
| 717 | } |
| 718 | DBUG_VOID_RETURN; |
| 719 | } |
| 720 | |
| 721 | |
| 722 | /** |
no test coverage detected