Commit d84e2a7d authored by unknown's avatar unknown

Merge desktop.sanja.is.com.ua:/home/bell/mysql/bk/mysql-maria

into  desktop.sanja.is.com.ua:/home/bell/mysql/bk/work-maria-bug35040


storage/maria/unittest/ma_pagecache_rwconsist.c:
  Auto merged
parents 3ad08736 047ce0dc
......@@ -140,55 +140,58 @@ void wqueue_release_queue(WQUEUE *wqueue)
@brief Removes all threads waiting for read or first one waiting for write.
@param wqueue pointer to the queue structure
@apram thread pointer to the thread to be added to the queue
@param thread pointer to the thread to be added to the queue
@note This function is applicable only to single linked lists.
*/
void wqueue_release_one_locktype_from_queue(WQUEUE *wqueue)
{
struct st_my_thread_var *last= wqueue->last_thread;
struct st_my_thread_var *next= last->next;
struct st_my_thread_var **prev= &last->next;
struct st_my_thread_var *thread;
struct st_my_thread_var *new_last= NULL;
struct st_my_thread_var *new_list= NULL;
uint first_type= next->lock_type;
if (first_type == MY_PTHREAD_LOCK_WRITE)
{
/* release first waiting for write lock */
thread= next;
pthread_cond_signal(&thread->suspend);
if (thread == last)
pthread_cond_signal(&next->suspend);
#ifndef DBUG_OFF
next->prev= NULL; /* force segfault if used */
#endif
if (next == last)
wqueue->last_thread= NULL;
*prev= thread->next;
thread->next= NULL;
else
last->next= next->next;
next->next= NULL;
return;
}
do
{
thread= next;
next= thread->next;
#ifndef DBUG_OFF
thread->prev= NULL; /* force segfault if used */
#endif
if (thread->lock_type == MY_PTHREAD_LOCK_WRITE)
{
/* skip waiting for write lock */
*prev= thread;
prev= &thread->next;
new_last= NULL;
if (new_list)
{
thread->next= new_list->next;
new_list= new_list->next= thread;
}
else
new_list= thread->next= thread;
}
else
{
/* release waiting for read lock */
pthread_cond_signal(&thread->suspend);
new_last= thread->next;
thread->next= NULL;
}
} while (thread != last);
if (new_last)
{
/* last was deleted */
if (new_last == last)
wqueue->last_thread= NULL; /* empty list */
else
wqueue->last_thread= new_last;
}
wqueue->last_thread= new_list;
}
......
......@@ -37,7 +37,7 @@ static char *file1_name= (char*)"page_cache_test_file_1";
static PAGECACHE_FILE file1;
static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count;
static uint thread_count;
static uint thread_count= 0;
static PAGECACHE pagecache;
static uint number_of_readers= 5;
......@@ -214,7 +214,7 @@ int main(int argc __attribute__((unused)),
#if defined(__WIN__)
default_dbug_option= "d:t:i:O,\\test_pagecache_consist.trace";
#else
default_dbug_option= "d:t:i:o,/tmp/test_pagecache_consist.trace";
default_dbug_option= "d:t:i:O,/tmp/test_pagecache_consist.trace";
#endif
if (argc > 1)
{
......@@ -335,8 +335,8 @@ int main(int argc __attribute__((unused)),
pthread_mutex_lock(&LOCK_thread_count);
while (thread_count)
{
if ((error= pthread_cond_wait(&COND_thread_count,&LOCK_thread_count)))
diag("COND_thread_count: %d from pthread_cond_wait\n",error);
if ((error= pthread_cond_wait(&COND_thread_count, &LOCK_thread_count)))
diag("COND_thread_count: %d from pthread_cond_wait\n", error);
}
pthread_mutex_unlock(&LOCK_thread_count);
DBUG_PRINT("info", ("thread ended"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment