diff options
Diffstat (limited to 'sql/log.cc')
-rw-r--r-- | sql/log.cc | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/sql/log.cc b/sql/log.cc index b583c6dfac4..70e74de5a31 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -6961,8 +6961,9 @@ int TC_LOG_MMAP::open(const char *opt_name) syncing= 0; active=pages; + DBUG_ASSERT(npages >= 2); pool=pages+1; - pool_last=pages+npages-1; + pool_last_ptr= &((pages+npages-1)->next); commit_ordered_queue= NULL; commit_ordered_queue_busy= false; @@ -6995,8 +6996,8 @@ void TC_LOG_MMAP::get_active_from_pool() do { best_p= p= &pool; - if ((*p)->waiters == 0) // can the first page be used ? - break; // yes - take it. + if ((*p)->waiters == 0 && (*p)->free > 0) // can the first page be used ? + break; // yes - take it. best_free=0; // no - trying second strategy for (p=&(*p)->next; *p; p=&(*p)->next) @@ -7013,10 +7014,10 @@ void TC_LOG_MMAP::get_active_from_pool() mysql_mutex_assert_owner(&LOCK_active); active=*best_p; - if ((*best_p)->next) // unlink the page from the pool - *best_p=(*best_p)->next; - else - pool_last=*best_p; + /* Unlink the page from the pool. */ + if (!(*best_p)->next) + pool_last_ptr= best_p; + *best_p=(*best_p)->next; mysql_mutex_unlock(&LOCK_pool); mysql_mutex_lock(&active->lock); @@ -7123,12 +7124,9 @@ int TC_LOG_MMAP::log_one_transaction(my_xid xid) mysql_mutex_unlock(&LOCK_active); mysql_mutex_lock(&p->lock); p->waiters++; - for (;;) + while (p->state == PS_DIRTY && syncing) { - int not_dirty = p->state != PS_DIRTY; mysql_mutex_unlock(&p->lock); - if (not_dirty || !syncing) - break; mysql_cond_wait(&p->cond, &LOCK_sync); mysql_mutex_lock(&p->lock); } @@ -7180,8 +7178,8 @@ int TC_LOG_MMAP::sync() /* page is synced. let's move it to the pool */ mysql_mutex_lock(&LOCK_pool); - pool_last->next=syncing; - pool_last=syncing; + (*pool_last_ptr)=syncing; + pool_last_ptr=&(syncing->next); syncing->next=0; syncing->state= err ? PS_ERROR : PS_POOL; mysql_cond_signal(&COND_pool); // in case somebody's waiting |