From 4e5d02e99f44b012671ade0373cf1c11a573abc4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Aug 2007 17:25:48 +0300 Subject: Fix for Bug#27970 "Fix for bug 24507 makes mysql_install_db fail" include/my_pthread.h: Fix for Bug#27970 "Fix for bug 24507 makes mysql_install_db fail". Removed macro NPTL_PTHREAD_EXIT_BUG, because it doesn't work in dynamic environment. One can switch between NPTL and LT on the fly on Linux. Added pthread_dummy(ESRCH) for those platforms that don't have pthread_kill. This ensures that there won't be an error in mysqld.cc where the return value is being checked from the function call. mysys/my_thr_init.c: Check for a Linux is enough. There is an additional test if NPTL is in use before spwaning the extra thread. --- mysys/my_thr_init.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'mysys/my_thr_init.c') diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index cf7ea0a800f..c446808c7da 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -47,7 +47,7 @@ pthread_mutexattr_t my_fast_mutexattr; pthread_mutexattr_t my_errorcheck_mutexattr; #endif -#ifdef NPTL_PTHREAD_EXIT_BUG /* see my_pthread.h */ +#ifdef TARGET_OS_LINUX /* Dummy thread spawned in my_thread_global_init() below to avoid @@ -62,7 +62,7 @@ nptl_pthread_exit_hack_handler(void *arg __attribute__((unused))) return 0; } -#endif +#endif /* TARGET_OS_LINUX */ static uint get_thread_lib(void); @@ -88,7 +88,7 @@ my_bool my_thread_global_init(void) return 1; } -#ifdef NPTL_PTHREAD_EXIT_BUG +#ifdef TARGET_OS_LINUX /* BUG#24507: Race conditions inside current NPTL pthread_exit() implementation. @@ -112,7 +112,7 @@ my_bool my_thread_global_init(void) pthread_create(&dummy_thread,&dummy_thread_attr, nptl_pthread_exit_hack_handler, NULL); } -#endif +#endif /* TARGET_OS_LINUX */ #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP /* @@ -178,10 +178,17 @@ void my_thread_global_end(void) &abstime); if (error == ETIMEDOUT || error == ETIME) { +#ifdef HAVE_PTHREAD_KILL + /* + We shouldn't give an error here, because if we don't have + pthread_kill(), programs like mysqld can't ensure that all threads + are killed when we enter here. + */ if (THR_thread_count) fprintf(stderr, "Error in my_thread_global_end(): %d threads didn't exit\n", THR_thread_count); +#endif all_threads_killed= 0; break; } @@ -206,7 +213,7 @@ void my_thread_global_end(void) if (all_threads_killed) { pthread_mutex_destroy(&THR_LOCK_threads); - pthread_cond_destroy (&THR_COND_threads); + pthread_cond_destroy(&THR_COND_threads); } #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) pthread_mutex_destroy(&LOCK_localtime_r); -- cgit v1.2.1