summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc24
1 files changed, 11 insertions, 13 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 05e8a66ed04..1aea7a33e0d 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -6322,8 +6322,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;
@@ -6356,8 +6357,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)
@@ -6374,10 +6375,10 @@ void TC_LOG_MMAP::get_active_from_pool()
safe_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;
pthread_mutex_unlock(&LOCK_pool);
pthread_mutex_lock(&active->lock);
@@ -6484,12 +6485,9 @@ int TC_LOG_MMAP::log_one_transaction(my_xid xid)
pthread_mutex_unlock(&LOCK_active);
pthread_mutex_lock(&p->lock);
p->waiters++;
- for (;;)
+ while (p->state == DIRTY && syncing)
{
- int not_dirty = p->state != DIRTY;
pthread_mutex_unlock(&p->lock);
- if (not_dirty || !syncing)
- break;
pthread_cond_wait(&p->cond, &LOCK_sync);
pthread_mutex_lock(&p->lock);
}
@@ -6541,8 +6539,8 @@ int TC_LOG_MMAP::sync()
/* page is synced. let's move it to the pool */
pthread_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 ? ERROR : POOL;
pthread_cond_signal(&COND_pool); // in case somebody's waiting