summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <istruewing@chilla.local>2007-03-28 16:23:44 +0200
committerunknown <istruewing@chilla.local>2007-03-28 16:23:44 +0200
commit8f93150d20e9af978c43deb4f90cc21457bd29db (patch)
treeddb8eae409cc02ad20aeed6d597552836232bdd4 /sql
parenta79e08a6e109982688cf37e5486282aa2af2a18d (diff)
downloadmariadb-git-8f93150d20e9af978c43deb4f90cc21457bd29db.tar.gz
restored run-time thread lib detection
sql/stacktrace.c: removed code duplication sql/stacktrace.h: removed code duplication
Diffstat (limited to 'sql')
-rw-r--r--sql/mysqld.cc34
-rw-r--r--sql/stacktrace.c17
-rw-r--r--sql/stacktrace.h2
3 files changed, 21 insertions, 32 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index a0687929de5..c5933484675 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -195,12 +195,6 @@ inline void reset_floating_point_exceptions()
} /* cplusplus */
-
-#if defined(HAVE_LINUXTHREADS)
-#define THR_KILL_SIGNAL SIGINT
-#else
-#define THR_KILL_SIGNAL SIGUSR2 // Can't use this with LinuxThreads
-#endif
#define MYSQL_KILL_SIGNAL SIGTERM
#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
@@ -605,6 +599,7 @@ pthread_mutex_t LOCK_server_started;
pthread_cond_t COND_server_started;
int mysqld_server_started= 0;
+static uint thr_kill_signal;
File_parser_dummy_hook file_parser_dummy_hook;
@@ -788,7 +783,7 @@ static void close_connections(void)
DBUG_PRINT("info",("Waiting for select thread"));
#ifndef DONT_USE_THR_ALARM
- if (pthread_kill(select_thread,THR_CLIENT_ALARM))
+ if (pthread_kill(select_thread, thr_client_alarm))
break; // allready dead
#endif
set_timespec(abstime, 2);
@@ -2294,7 +2289,9 @@ static void init_signals(void)
DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT)
- my_sigset(THR_KILL_SIGNAL,end_thread_signal);
+ {
+ my_sigset(thr_kill_signal, end_thread_signal);
+ }
my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
@@ -2351,8 +2348,12 @@ static void init_signals(void)
#endif
sigaddset(&set,THR_SERVER_ALARM);
if (test_flags & TEST_SIGINT)
- sigdelset(&set,THR_KILL_SIGNAL); // May be SIGINT
- sigdelset(&set,THR_CLIENT_ALARM); // For alarms
+ {
+ // May be SIGINT
+ sigdelset(&set, thr_kill_signal);
+ }
+ // For alarms
+ sigdelset(&set, thr_client_alarm);
sigprocmask(SIG_SETMASK,&set,NULL);
pthread_sigmask(SIG_SETMASK,&set,NULL);
DBUG_VOID_RETURN;
@@ -2415,24 +2416,20 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
*/
init_thr_alarm(thread_scheduler.max_threads +
global_system_variables.max_insert_delayed_threads + 10);
-#if SIGINT != THR_KILL_SIGNAL
- if (test_flags & TEST_SIGINT)
+ if (thd_lib_detected != THD_LIB_LT && (test_flags & TEST_SIGINT))
{
(void) sigemptyset(&set); // Setup up SIGINT for debug
(void) sigaddset(&set,SIGINT); // For debugging
(void) pthread_sigmask(SIG_UNBLOCK,&set,NULL);
}
-#endif
(void) sigemptyset(&set); // Setup up SIGINT for debug
#ifdef USE_ONE_SIGNAL_HAND
(void) sigaddset(&set,THR_SERVER_ALARM); // For alarms
#endif
#ifndef IGNORE_SIGHUP_SIGQUIT
(void) sigaddset(&set,SIGQUIT);
-#if THR_CLIENT_ALARM != SIGHUP
(void) sigaddset(&set,SIGHUP);
#endif
-#endif
(void) sigaddset(&set,SIGTERM);
(void) sigaddset(&set,SIGTSTP);
@@ -3626,6 +3623,13 @@ int main(int argc, char **argv)
MY_INIT(argv[0]); // init my_sys library & pthreads
/* nothing should come before this line ^^^ */
+ /* Set signal used to kill MySQL */
+#if defined(SIGUSR2)
+ thr_kill_signal= thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2;
+#else
+ thr_kill_signal= SIGINT;
+#endif
+
/*
Perform basic logger initialization logger. Should be called after
MY_INIT, as it initializes mutexes. Log tables are inited later.
diff --git a/sql/stacktrace.c b/sql/stacktrace.c
index d8e9b7fd883..0dbf4522a71 100644
--- a/sql/stacktrace.c
+++ b/sql/stacktrace.c
@@ -55,19 +55,6 @@ void safe_print_str(const char* name, const char* val, int max_len)
static my_bool is_nptl;
-/* Check if we are using NPTL or LinuxThreads on Linux */
-void check_thread_lib(void)
-{
- char buf[5];
-
-#ifdef _CS_GNU_LIBPTHREAD_VERSION
- confstr(_CS_GNU_LIBPTHREAD_VERSION, buf, sizeof(buf));
- is_nptl = !strncasecmp(buf, "NPTL", sizeof(buf));
-#else
- is_nptl = 0;
-#endif
-}
-
#if defined(__alpha__) && defined(__GNUC__)
/*
The only way to backtrace without a symbol table on alpha
@@ -173,8 +160,8 @@ terribly wrong...\n");
#endif /* __alpha__ */
/* We are 1 frame above signal frame with NPTL and 2 frames above with LT */
- sigreturn_frame_count = is_nptl ? 1 : 2;
-
+ sigreturn_frame_count = thd_lib_detected == THD_LIB_LT ? 2 : 1;
+
while (fp < (uchar**) stack_bottom)
{
#if defined(__i386__) || defined(__x86_64__)
diff --git a/sql/stacktrace.h b/sql/stacktrace.h
index f5c92e54e1c..56b9877180a 100644
--- a/sql/stacktrace.h
+++ b/sql/stacktrace.h
@@ -27,11 +27,9 @@ extern char* heap_start;
#define init_stacktrace() do { \
heap_start = (char*) &__bss_start; \
- check_thread_lib(); \
} while(0);
void print_stacktrace(gptr stack_bottom, ulong thread_stack);
void safe_print_str(const char* name, const char* val, int max_len);
-void check_thread_lib(void);
#endif /* (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) */
#endif /* TARGET_OS_LINUX */