diff options
author | unknown <istruewing@chilla.local> | 2007-02-01 10:19:22 +0100 |
---|---|---|
committer | unknown <istruewing@chilla.local> | 2007-02-01 10:19:22 +0100 |
commit | 8772cb168b43528a2fcef03ece3078f58cb34d40 (patch) | |
tree | 022725674254e6cf9a1dda24210e53fd3dc844fd | |
parent | ad7a4ebbe31d3bd6113e5f26107db6fffaddea1c (diff) | |
parent | 62fdcb54a7e03282b19b8661e0f78e766e3b2a36 (diff) | |
download | mariadb-git-8772cb168b43528a2fcef03ece3078f58cb34d40.tar.gz |
Merge chilla.local:/home/mydev/mysql-4.1-axmrg
into chilla.local:/home/mydev/mysql-5.0-axmrg
include/my_global.h:
Auto merged
include/thr_alarm.h:
Auto merged
mysys/my_pthread.c:
Auto merged
mysys/thr_alarm.c:
Auto merged
include/my_pthread.h:
Manual merged
mysys/default.c:
Manual merged
mysys/my_thr_init.c:
Manual merged
sql/mysqld.cc:
Manual merged
-rw-r--r-- | include/my_global.h | 5 | ||||
-rw-r--r-- | include/my_pthread.h | 18 | ||||
-rw-r--r-- | include/thr_alarm.h | 2 | ||||
-rw-r--r-- | mysys/my_pthread.c | 5 | ||||
-rw-r--r-- | mysys/my_thr_init.c | 25 | ||||
-rw-r--r-- | mysys/thr_alarm.c | 26 | ||||
-rw-r--r-- | sql/mysqld.cc | 34 |
7 files changed, 64 insertions, 51 deletions
diff --git a/include/my_global.h b/include/my_global.h index 306aabd15fe..b91ff8a9e5b 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -454,10 +454,7 @@ int __void__; #endif /* Define some useful general macros */ -#if defined(__cplusplus) && defined(__GNUC__) -#define max(a, b) ((a) >? (b)) -#define min(a, b) ((a) <? (b)) -#elif !defined(max) +#if !defined(max) #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) #endif diff --git a/include/my_pthread.h b/include/my_pthread.h index cf6ae8cd6a1..6ebde2f119c 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -30,14 +30,6 @@ extern "C" { #define EXTERNC #endif /* __cplusplus */ -/* Thread library */ - -#define THD_LIB_OTHER 1 -#define THD_LIB_NPTL 2 -#define THD_LIB_LT 4 - -extern uint thd_lib_detected; - /* BUG#24507: Race conditions inside current NPTL pthread_exit() implementation. @@ -771,6 +763,16 @@ extern uint my_thread_end_wait_time; Keep track of shutdown,signal, and main threads so that my_end() will not report errors with them */ + +/* Which kind of thread library is in use */ + +#define THD_LIB_OTHER 1 +#define THD_LIB_NPTL 2 +#define THD_LIB_LT 4 + +extern uint thd_lib_detected; +extern uint thr_client_alarm; + /* statistics_xxx functions are for not essential statistic */ #ifndef thread_safe_increment diff --git a/include/thr_alarm.h b/include/thr_alarm.h index fb7b9762b10..4127c9cb35e 100644 --- a/include/thr_alarm.h +++ b/include/thr_alarm.h @@ -92,6 +92,8 @@ typedef struct st_alarm { my_bool malloced; } ALARM; +extern uint thr_client_alarm; + #define thr_alarm_init(A) (*(A))=0 #define thr_alarm_in_use(A) (*(A)!= 0) void init_thr_alarm(uint max_alarm); diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index ce80dc014c2..afdce8342a6 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -30,6 +30,7 @@ #endif uint thd_lib_detected; +uint thr_client_alarm; #ifndef my_pthread_setprio void my_pthread_setprio(pthread_t thread_id,int prior) @@ -337,7 +338,9 @@ void *sigwait_thread(void *set_arg) sigaction(i, &sact, (struct sigaction*) 0); } } - sigaddset(set, thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1); + /* Ensure that init_thr_alarm() is called */ + DBUG_ASSERT(thr_client_alarm); + sigaddset(set, thr_client_alarm); pthread_sigmask(SIG_UNBLOCK,(sigset_t*) set,(sigset_t*) 0); alarm_thread=pthread_self(); /* For thr_alarm */ diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index c5105dc4e1e..b364498fb48 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -20,6 +20,7 @@ #include "mysys_priv.h" #include <m_string.h> +#include <signal.h> #ifdef THREAD #ifdef USE_TLS @@ -63,6 +64,8 @@ pthread_handler_t nptl_pthread_exit_hack_handler(void *arg) #endif +static uint get_thread_lib(void); + /* initialize thread environment @@ -76,6 +79,12 @@ pthread_handler_t nptl_pthread_exit_hack_handler(void *arg) my_bool my_thread_global_init(void) { + thd_lib_detected= get_thread_lib(); + if (thd_lib_detected == THD_LIB_LT) + thr_client_alarm= SIGALRM; + else + thr_client_alarm= SIGUSR1; + if (pthread_key_create(&THR_KEY_mysys,0)) { fprintf(stderr,"Can't initialize threads: error %d\n",errno); @@ -392,4 +401,20 @@ const char *my_thread_name(void) } #endif /* DBUG_OFF */ + +static uint get_thread_lib(void) +{ + char buff[64]; + +#ifdef _CS_GNU_LIBPTHREAD_VERSION + confstr(_CS_GNU_LIBPTHREAD_VERSION, buff, sizeof(buff)); + + if (!strncasecmp(buff, "NPTL", 4)) + return THD_LIB_NPTL; + if (!strncasecmp(buff, "linuxthreads", 12)) + return THD_LIB_LT; +#endif + return THD_LIB_OTHER; +} + #endif /* THREAD */ diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 44fd380c082..d11883a4ea4 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -35,6 +35,7 @@ #define ETIME ETIMEDOUT #endif +uint thr_client_alarm; static int alarm_aborted=1; /* No alarm thread */ my_bool thr_alarm_inited= 0; volatile my_bool alarm_thread_running= 0; @@ -76,12 +77,15 @@ void init_thr_alarm(uint max_alarms) sigfillset(&full_signal_set); /* Neaded to block signals */ pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST); pthread_cond_init(&COND_alarm,NULL); + if (thd_lib_detected == THD_LIB_LT) + thr_client_alarm= SIGALRM; + else + thr_client_alarm= SIGUSR1; #ifndef USE_ALARM_THREAD if (thd_lib_detected != THD_LIB_LT) #endif { - my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1, - thread_alarm); + my_sigset(thr_client_alarm, thread_alarm); } sigemptyset(&s); sigaddset(&s, THR_SERVER_ALARM); @@ -102,8 +106,7 @@ void init_thr_alarm(uint max_alarms) pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */ if (thd_lib_detected == THD_LIB_LT) { - my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1, - process_alarm); /* Linuxthreads */ + my_sigset(thr_client_alarm, process_alarm); /* Linuxthreads */ pthread_sigmask(SIG_UNBLOCK, &s, NULL); } #else @@ -283,8 +286,7 @@ sig_handler process_alarm(int sig __attribute__((unused))) printf("thread_alarm in process_alarm\n"); fflush(stdout); #endif #ifdef DONT_REMEMBER_SIGNAL - my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1, - process_alarm); /* int. thread system calls */ + my_sigset(thr_client_alarm, process_alarm); /* int. thread system calls */ #endif return; } @@ -331,8 +333,7 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused))) alarm_data=(ALARM*) queue_element(&alarm_queue,i); alarm_data->alarmed=1; /* Info to thread */ if (pthread_equal(alarm_data->thread,alarm_thread) || - pthread_kill(alarm_data->thread, - thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1)) + pthread_kill(alarm_data->thread, thr_client_alarm)) { #ifdef MAIN printf("Warning: pthread_kill couldn't find thread!!!\n"); @@ -356,8 +357,7 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused))) alarm_data->alarmed=1; /* Info to thread */ DBUG_PRINT("info",("sending signal to waiting thread")); if (pthread_equal(alarm_data->thread,alarm_thread) || - pthread_kill(alarm_data->thread, - thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1)) + pthread_kill(alarm_data->thread, thr_client_alarm)) { #ifdef MAIN printf("Warning: pthread_kill couldn't find thread!!!\n"); @@ -943,7 +943,7 @@ static void *signal_hand(void *arg __attribute__((unused))) #endif #endif /* OS2 */ printf("server alarm: %d thread alarm: %d\n", - THR_SERVER_ALARM, thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1); + THR_SERVER_ALARM, thr_client_alarm); DBUG_PRINT("info",("Starting signal and alarm handling thread")); for(;;) { @@ -1015,11 +1015,11 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) sigaddset(&set,SIGTSTP); #endif sigaddset(&set,THR_SERVER_ALARM); - sigdelset(&set, thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1); + sigdelset(&set, thr_client_alarm); (void) pthread_sigmask(SIG_SETMASK,&set,NULL); #ifdef NOT_USED sigemptyset(&set); - sigaddset(&set, thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1); + sigaddset(&set, thr_client_alarm); VOID(pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0)); #endif #endif /* OS2 */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e62cec321b1..5dcfc45be6f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -517,6 +517,7 @@ rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; pthread_cond_t COND_refresh,COND_thread_count, COND_global_read_lock; pthread_t signal_thread; pthread_attr_t connection_attrib; +static uint thr_kill_signal; File_parser_dummy_hook file_parser_dummy_hook; @@ -653,7 +654,6 @@ static void clean_up_mutexes(void); static void wait_for_signal_thread_to_end(void); static int test_if_case_insensitive(const char *dir_name); static void create_pid_file(); -static uint get_thread_lib(void); #ifndef EMBEDDED_LIBRARY /**************************************************************************** @@ -693,8 +693,7 @@ static void close_connections(void) DBUG_PRINT("info",("Waiting for select thread")); #ifndef DONT_USE_THR_ALARM - if (pthread_kill(select_thread, - thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1)) + if (pthread_kill(select_thread, thr_client_alarm)) break; // allready dead #endif set_timespec(abstime, 2); @@ -2151,8 +2150,7 @@ static void init_signals(void) if (test_flags & TEST_SIGINT) { - my_sigset(thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2, - end_thread_signal); + my_sigset(thr_kill_signal, end_thread_signal); } my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called! @@ -2212,10 +2210,10 @@ static void init_signals(void) if (test_flags & TEST_SIGINT) { // May be SIGINT - sigdelset(&set, thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2); + sigdelset(&set, thr_kill_signal); } // For alarms - sigdelset(&set, thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1); + sigdelset(&set, thr_client_alarm); sigprocmask(SIG_SETMASK,&set,NULL); pthread_sigmask(SIG_SETMASK,&set,NULL); DBUG_VOID_RETURN; @@ -2279,7 +2277,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) */ init_thr_alarm(max_connections + global_system_variables.max_insert_delayed_threads + 10); - if (thd_lib_detected != THD_LIB_LT && 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 @@ -3350,6 +3348,9 @@ int main(int argc, char **argv) DEBUGGER_OFF; + /* Set signal used to kill MySQL */ + thr_kill_signal= thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2; + #ifdef _CUSTOMSTARTUPCONFIG_ if (_cust_check_startup()) { @@ -3374,7 +3375,6 @@ int main(int argc, char **argv) } #endif /* __WIN__ */ - thd_lib_detected= get_thread_lib(); if (init_common_variables(MYSQL_CONFIG_NAME, argc, argv, load_default_groups)) unireg_abort(1); // Will do exit @@ -7545,22 +7545,6 @@ static void create_pid_file() } -static uint get_thread_lib(void) -{ - char buff[64]; - -#ifdef _CS_GNU_LIBPTHREAD_VERSION - confstr(_CS_GNU_LIBPTHREAD_VERSION, buff, sizeof(buff)); - - if (!strncasecmp(buff, "NPTL", 4)) - return THD_LIB_NPTL; - else if (!strncasecmp(buff, "linuxthreads", 12)) - return THD_LIB_LT; -#endif - return THD_LIB_OTHER; -} - - /* Clear most status variables */ void refresh_status(THD *thd) { |