mirror of
https://github.com/MariaDB/server.git
synced 2025-02-01 19:41:47 +01:00
refs #5730, make cachefiles list a doubly linked list for more efficient close, helps shutdown
git-svn-id: file:///svn/toku/tokudb@50881 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
5a95388095
commit
d605f812fb
2 changed files with 13 additions and 9 deletions
|
@ -94,6 +94,7 @@ class pair_list;
|
|||
//
|
||||
struct cachefile {
|
||||
CACHEFILE next;
|
||||
CACHEFILE prev;
|
||||
bool for_checkpoint; //True if part of the in-progress checkpoint
|
||||
|
||||
// If set and the cachefile closes, the file will be removed.
|
||||
|
|
|
@ -353,6 +353,10 @@ int toku_cachetable_openfd_with_filenum (CACHEFILE *cfptr, CACHETABLE ct, int fd
|
|||
newcf->filenum = filenum;
|
||||
cachefile_init_filenum(newcf, fd, fname_in_env, fileid);
|
||||
newcf->next = ct->cf_list.m_head;
|
||||
newcf->prev = NULL;
|
||||
if (ct->cf_list.m_head) {
|
||||
ct->cf_list.m_head->prev = newcf;
|
||||
}
|
||||
ct->cf_list.m_head = newcf;
|
||||
|
||||
bjm_init(&newcf->bjm);
|
||||
|
@ -425,16 +429,15 @@ static void remove_cf_from_cachefiles_list (CACHEFILE cf) {
|
|||
CACHETABLE ct = cf->cachetable;
|
||||
ct->cf_list.write_lock();
|
||||
invariant(ct->cf_list.m_head != NULL);
|
||||
if (cf == ct->cf_list.m_head) {
|
||||
ct->cf_list.m_head = cf->next;
|
||||
if (cf->next) {
|
||||
cf->next->prev = cf->prev;
|
||||
}
|
||||
else {
|
||||
CACHEFILE curr_cf = ct->cf_list.m_head;
|
||||
while (curr_cf->next != cf) {
|
||||
curr_cf = curr_cf->next;
|
||||
}
|
||||
// at this point, curr_cf->next is pointing to cf
|
||||
curr_cf->next = cf->next;
|
||||
if (cf->prev) {
|
||||
cf->prev->next = cf->next;
|
||||
}
|
||||
if (cf == ct->cf_list.m_head) {
|
||||
invariant(cf->prev == NULL);
|
||||
ct->cf_list.m_head = cf->next;
|
||||
}
|
||||
ct->cf_list.write_unlock();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue