diff options
author | Vladislav Vaintroub <wlad@sun.com> | 2010-01-16 05:04:02 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@sun.com> | 2010-01-16 05:04:02 +0100 |
commit | 508959134ba4805283e04177de8db0a4144debbf (patch) | |
tree | e046cc7b05958e2078914db23d3ff620e377550b /mysys | |
parent | e0b7046b4f4630a4ddfa8edac00cd4e7c26f8b5c (diff) | |
download | mariadb-git-508959134ba4805283e04177de8db0a4144debbf.tar.gz |
Bug#50362:
Init MY_PTHREAD_MUTEX_FAST prior to first usage to avoid crash on
FreeBSD
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_thr_init.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 83d35863eca..33a6b2eb615 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -88,6 +88,21 @@ my_bool my_thread_basic_global_init(void) return 0; my_thread_basic_global_init_done= 1; +#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP + /* + Set mutex type to "fast" a.k.a "adaptive" + + In this case the thread may steal the mutex from some other thread + that is waiting for the same mutex. This will save us some + context switches but may cause a thread to 'starve forever' while + waiting for the mutex (not likely if the code within the mutex is + short). + */ + pthread_mutexattr_init(&my_fast_mutexattr); + pthread_mutexattr_settype(&my_fast_mutexattr, + PTHREAD_MUTEX_ADAPTIVE_NP); +#endif + mysql_mutex_init(key_THR_LOCK_malloc, &THR_LOCK_malloc, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_THR_LOCK_open, &THR_LOCK_open, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_THR_LOCK_charset, &THR_LOCK_charset, MY_MUTEX_INIT_FAST); @@ -190,20 +205,6 @@ my_bool my_thread_global_init(void) } #endif /* TARGET_OS_LINUX */ -#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP - /* - Set mutex type to "fast" a.k.a "adaptive" - - In this case the thread may steal the mutex from some other thread - that is waiting for the same mutex. This will save us some - context switches but may cause a thread to 'starve forever' while - waiting for the mutex (not likely if the code within the mutex is - short). - */ - pthread_mutexattr_init(&my_fast_mutexattr); - pthread_mutexattr_settype(&my_fast_mutexattr, - PTHREAD_MUTEX_ADAPTIVE_NP); -#endif #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP /* Set mutex type to "errorcheck" |