diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-09-03 12:58:41 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-09-03 12:58:41 +0200 |
commit | 530a6e74819ec14b5fdc42aa588b236ecb9f2fcd (patch) | |
tree | a4d45b1fd0e434c23577507364fa443226676eb5 /mysys | |
parent | 5088cbf4ed7224698678f3eaf406361c6e7db4b8 (diff) | |
parent | 4b41e3c7f33714186c97a6cc2e6d3bb93b050c61 (diff) | |
download | mariadb-git-530a6e74819ec14b5fdc42aa588b236ecb9f2fcd.tar.gz |
Merge branch '10.0' into 10.1
referenced_by_foreign_key2(), needed for InnoDB to compile,
was taken from 10.0-galera
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/mf_keycache.c | 36 | ||||
-rw-r--r-- | mysys/mulalloc.c | 44 | ||||
-rw-r--r-- | mysys/my_thr_init.c | 2 | ||||
-rw-r--r-- | mysys/ptr_cmp.c | 3 | ||||
-rw-r--r-- | mysys/thr_alarm.c | 12 | ||||
-rw-r--r-- | mysys/thr_lock.c | 12 |
6 files changed, 83 insertions, 26 deletions
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index dc809df75cb..d9bc0e9094e 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -552,17 +552,21 @@ int init_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache, Allocate memory for blocks, hash_links and hash entries; For each block 2 hash links are allocated */ - if (my_multi_malloc(MYF(MY_ZEROFILL), - &keycache->block_root, blocks * sizeof(BLOCK_LINK), - &keycache->hash_root, - sizeof(HASH_LINK*) * keycache->hash_entries, - &keycache->hash_link_root, - hash_links * sizeof(HASH_LINK), - &keycache->changed_blocks, - sizeof(BLOCK_LINK*) * changed_blocks_hash_size, - &keycache->file_blocks, - sizeof(BLOCK_LINK*) * changed_blocks_hash_size, - NullS)) + if (my_multi_malloc_large(MYF(MY_ZEROFILL), + &keycache->block_root, + (ulonglong) (blocks * sizeof(BLOCK_LINK)), + &keycache->hash_root, + (ulonglong) (sizeof(HASH_LINK*) * + keycache->hash_entries), + &keycache->hash_link_root, + (ulonglong) (hash_links * sizeof(HASH_LINK)), + &keycache->changed_blocks, + (ulonglong) (sizeof(BLOCK_LINK*) * + changed_blocks_hash_size), + &keycache->file_blocks, + (ulonglong) (sizeof(BLOCK_LINK*) * + changed_blocks_hash_size), + NullS)) break; my_large_free(keycache->block_mem); keycache->block_mem= 0; @@ -1123,6 +1127,7 @@ static void wait_on_queue(KEYCACHE_WQUEUE *wqueue, struct st_my_thread_var *thread= my_thread_var; DBUG_ASSERT(!thread->next); DBUG_ASSERT(!thread->prev); /* Not required, but must be true anyway. */ + mysql_mutex_assert_owner(mutex); /* Add to queue. */ if (! (last= wqueue->last_thread)) @@ -1177,14 +1182,15 @@ static void release_whole_queue(KEYCACHE_WQUEUE *wqueue) do { thread=next; - DBUG_ASSERT(thread); + DBUG_ASSERT(thread && thread->init == 1); KEYCACHE_DBUG_PRINT("release_whole_queue: signal", ("thread %ld", thread->id)); - /* Signal the thread. */ - keycache_pthread_cond_signal(&thread->suspend); /* Take thread from queue. */ - next=thread->next; + next= thread->next; thread->next= NULL; + + /* Signal the thread. */ + keycache_pthread_cond_signal(&thread->suspend); } while (thread != last); diff --git a/mysys/mulalloc.c b/mysys/mulalloc.c index 9384ed744ad..fceecdc1dc7 100644 --- a/mysys/mulalloc.c +++ b/mysys/mulalloc.c @@ -62,3 +62,47 @@ void* my_multi_malloc(myf myFlags, ...) va_end(args); DBUG_RETURN((void*) start); } + + +/* + Same as my_multi_malloc, but each entry can be over 4G + + SYNOPSIS + my_multi_malloc() + myFlags Flags + ptr1, length1 Multiple arguments terminated by null ptr + ptr2, length2 ... + ... + NULL +*/ + +void *my_multi_malloc_large(myf myFlags, ...) +{ + va_list args; + char **ptr,*start,*res; + size_t tot_length,length; + DBUG_ENTER("my_multi_malloc"); + + va_start(args,myFlags); + tot_length=0; + while ((ptr=va_arg(args, char **))) + { + length=va_arg(args,ulonglong); + tot_length+=ALIGN_SIZE(length); + } + va_end(args); + + if (!(start=(char *) my_malloc(tot_length, myFlags))) + DBUG_RETURN(0); /* purecov: inspected */ + + va_start(args,myFlags); + res=start; + while ((ptr=va_arg(args, char **))) + { + *ptr=res; + length=va_arg(args,ulonglong); + res+=ALIGN_SIZE(length); + } + va_end(args); + DBUG_RETURN((void*) start); +} diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index d9dbacc8524..1e4b85583b1 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -372,6 +372,8 @@ void my_thread_end(void) mysql_cond_signal(&THR_COND_threads); mysql_mutex_unlock(&THR_LOCK_threads); + /* Trash variable so that we can detect false accesses to my_thread_var */ + tmp->init= 2; TRASH(tmp, sizeof(*tmp)); free(tmp); } diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c index d4daf2b1ec5..6d853a8db25 100644 --- a/mysys/ptr_cmp.c +++ b/mysys/ptr_cmp.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -91,6 +91,7 @@ static int ptr_compare(size_t *compare_length, uchar **a, uchar **b) size_t length= *compare_length; uchar *first,*last; + DBUG_ASSERT(length > 0); first= *a; last= *b; while (--length) { diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index d0bb2f1ef4c..9d917d3dd59 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -694,7 +694,7 @@ static void *test_thread(void *arg) thread_count--; mysql_cond_signal(&COND_thread_count); /* Tell main we are ready */ mysql_mutex_unlock(&LOCK_thread_count); - free((uchar*) arg); + my_thread_end(); return 0; } @@ -771,7 +771,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) { pthread_t tid; pthread_attr_t thr_attr; - int i,*param,error; + int i, param[2], error; sigset_t set; ALARM_INFO alarm_info; MY_INIT(argv[0]); @@ -815,12 +815,11 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) printf("Main thread: %s\n",my_thread_name()); for (i=0 ; i < 2 ; i++) { - param=(int*) malloc(sizeof(int)); - *param= i; + param[i]= i; mysql_mutex_lock(&LOCK_thread_count); if ((error= mysql_thread_create(0, &tid, &thr_attr, test_thread, - (void*) param))) + (void*) ¶m[i]))) { printf("Can't create thread %d, error: %d\n",i,error); exit(1); @@ -851,6 +850,9 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) alarm_info.active_alarms, alarm_info.max_used_alarms, alarm_info.next_alarm_time); printf("Test succeeded\n"); + mysql_cond_destroy(&COND_thread_count); + mysql_mutex_destroy(&LOCK_thread_count); + my_end(MY_CHECK_ERROR); return 0; } diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index dfff3b28440..8990cbd5a14 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -1849,7 +1849,7 @@ static void *test_thread(void *arg) thread_count--; mysql_cond_signal(&COND_thread_count); /* Tell main we are ready */ mysql_mutex_unlock(&LOCK_thread_count); - free((uchar*) arg); + my_thread_end(); return 0; } @@ -1858,7 +1858,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) { pthread_t tid; pthread_attr_t thr_attr; - int *param,error; + int param[array_elements(lock_counts)], error; uint i; MY_INIT(argv[0]); if (argc > 1 && argv[1][0] == '-' && argv[1][1] == '#') @@ -1914,8 +1914,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) #endif for (i=0 ; i < array_elements(lock_counts) ; i++) { - param=(int*) malloc(sizeof(int)); - *param=i; + param[i]= i; if ((error= mysql_mutex_lock(&LOCK_thread_count))) { @@ -1925,7 +1924,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) } if ((error= mysql_thread_create(0, &tid, &thr_attr, test_thread, - (void*) param))) + (void*) ¶m[i]))) { fprintf(stderr, "Got error: %d from mysql_thread_create (errno: %d)\n", error, errno); @@ -1954,6 +1953,9 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) else #endif printf("Test succeeded\n"); + mysql_cond_destroy(&COND_thread_count); + mysql_mutex_destroy(&LOCK_thread_count); + my_end(MY_CHECK_ERROR); return 0; } |