Below is the list of changes that have just been committed into a local
5.0 repository of jani. When jani does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-08-16 17:25:48+03:00, jani@stripped +3 -0
Fix for Bug#27970 "Fix for bug 24507 makes mysql_install_db fail"
include/my_pthread.h@stripped, 2007-08-16 17:25:45+03:00, jani@stripped +9 -23
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@stripped, 2007-08-16 17:25:45+03:00, jani@stripped +12 -5
Check for a Linux is enough. There is an additional test if
NPTL is in use before spwaning the extra thread.
sql/mysqld.cc@stripped, 2007-08-16 17:25:45+03:00, jani@stripped +1 -1
Fix for Bug#27970 "Fix for bug 24507 makes mysql_install_db fail"
diff -Nrup a/include/my_pthread.h b/include/my_pthread.h
--- a/include/my_pthread.h 2007-03-09 09:02:23 +02:00
+++ b/include/my_pthread.h 2007-08-16 17:25:45 +03:00
@@ -30,25 +30,6 @@ extern "C" {
#define EXTERNC
#endif /* __cplusplus */
-/*
- BUG#24507: Race conditions inside current NPTL pthread_exit() implementation.
-
- If macro NPTL_PTHREAD_EXIT_HACK is defined then a hack described in the bug
- report will be implemented inside my_thread_global_init() in my_thr_init.c.
-
- This amounts to spawning a dummy thread which does nothing but executes
- pthread_exit(0).
-
- This bug is fixed in version 2.5 of glibc library.
-
- TODO: Remove this code when fixed versions of glibc6 are in common use.
- */
-
-#if defined(TARGET_OS_LINUX) && defined(HAVE_NPTL) && \
- defined(__GLIBC__) && ( __GLIBC__ < 2 || __GLIBC__ == 2 &&
__GLIBC_MINOR__ < 5 )
-#define NPTL_PTHREAD_EXIT_BUG 1
-#endif
-
#if defined(__WIN__) || defined(OS2)
#ifdef OS2
@@ -199,7 +180,7 @@ extern int pthread_mutex_destroy (pthrea
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
-#define pthread_kill(A,B) pthread_dummy(0)
+#define pthread_kill(A,B) pthread_dummy(ESRCH)
#endif /* OS2 */
/* Dummy defines for easier code */
@@ -463,14 +444,14 @@ struct tm *gmtime_r(const time_t *clock,
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
-#define pthread_kill(A,B) pthread_dummy(0)
+#define pthread_kill(A,B) pthread_dummy(ESRCH)
#undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ;
pthread_detach(&tmp); }
#endif
#ifdef HAVE_DARWIN5_THREADS
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
-#define pthread_kill(A,B) pthread_dummy(0)
+#define pthread_kill(A,B) pthread_dummy(ESRCH)
#define pthread_condattr_init(A) pthread_dummy(0)
#define pthread_condattr_destroy(A) pthread_dummy(0)
#undef pthread_detach_this_thread
@@ -490,7 +471,7 @@ struct tm *gmtime_r(const time_t *clock,
#ifndef pthread_sigmask
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
#endif
-#define pthread_kill(A,B) pthread_dummy(0)
+#define pthread_kill(A,B) pthread_dummy(ESRCH)
#undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ;
pthread_detach(&tmp); }
#elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */
@@ -715,6 +696,11 @@ extern pthread_mutexattr_t my_errorcheck
#define MY_MUTEX_INIT_ERRCHK &my_errorcheck_mutexattr
#else
#define MY_MUTEX_INIT_ERRCHK NULL
+#endif
+
+#ifndef ESRCH
+/* Define it to something */
+#define ESRCH 1
#endif
extern my_bool my_thread_global_init(void);
diff -Nrup a/mysys/my_thr_init.c b/mysys/my_thr_init.c
--- a/mysys/my_thr_init.c 2007-06-07 10:48:36 +03:00
+++ b/mysys/my_thr_init.c 2007-08-16 17:25:45 +03:00
@@ -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
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);
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc 2007-08-05 06:53:12 +03:00
+++ b/sql/mysqld.cc 2007-08-16 17:25:45 +03:00
@@ -1233,7 +1233,7 @@ static void wait_for_signal_thread_to_en
*/
for (i= 0 ; i < 100 && signal_thread_in_use; i++)
{
- if (pthread_kill(signal_thread, MYSQL_KILL_SIGNAL))
+ if (pthread_kill(signal_thread, MYSQL_KILL_SIGNAL) != ESRCH)
break;
my_sleep(100); // Give it time to die
}
| Thread |
|---|
| • bk commit into 5.0 tree (jani:1.2494) BUG#27970 | jani | 16 Aug |