Commit 42bd03e2 authored by istruewing@chilla.local's avatar istruewing@chilla.local

Merge chilla.local:/home/mydev/mysql-4.1-axmrg

into  chilla.local:/home/mydev/mysql-5.0-axmrg
parents 45f61a06 79e099e8
***************
*** 39,46 ****
c_warnings="$global_warnings -Wunused"
cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor"
! alpha_cflags="-mcpu=ev6 -Wa,-mev6" # Not used yet
! pentium_cflags="-mcpu=pentiumpro"
sparc_cflags=""
# be as fast as we can be without losing our ability to backtrace
--- 39,46 ----
c_warnings="$global_warnings -Wunused"
cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor"
! #alpha_cflags="-mcpu=ev6 -Wa,-mev6" # Not used yet
! #pentium_cflags="-mcpu=pentiumpro"
sparc_cflags=""
# be as fast as we can be without losing our ability to backtrace
This diff is collapsed.
......@@ -454,7 +454,10 @@ int __void__;
#endif
/* Define some useful general macros */
#if !defined(max)
#if defined(__cplusplus) && defined(__GNUC__)
#define max(a, b) ((a) >? (b))
#define min(a, b) ((a) <? (b))
#elif !defined(max)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
......
***************
*** 97,103 ****
/* Fix problem with S_ISLNK() on Linux */
! #if defined(HAVE_LINUXTHREADS)
#undef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
--- 97,103 ----
/* Fix problem with S_ISLNK() on Linux */
! #if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
#undef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
......@@ -30,6 +30,14 @@ 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.
......@@ -49,7 +57,6 @@ extern "C" {
#define NPTL_PTHREAD_EXIT_BUG 1
#endif
#if defined(__WIN__) || defined(OS2)
#ifdef OS2
......
***************
*** 286,293 ****
#undef HAVE_PTHREAD_RWLOCK_RDLOCK
#undef HAVE_SNPRINTF
! #define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
! #define signal(A,B) pthread_signal((A),(void (*)(int)) (B))
#define my_pthread_attr_setprio(A,B)
#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */
--- 294,301 ----
#undef HAVE_PTHREAD_RWLOCK_RDLOCK
#undef HAVE_SNPRINTF
! #define my_sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
! #define my_signal(A,B) pthread_signal((A),(void (*)(int)) (B))
#define my_pthread_attr_setprio(A,B)
#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */
***************
*** 324,337 ****
#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
#endif
! #if !defined(HAVE_SIGSET) && !defined(HAVE_mit_thread) && !defined(sigset)
! #define sigset(A,B) do { struct sigaction s; sigset_t set; \
! sigemptyset(&set); \
! s.sa_handler = (B); \
! s.sa_mask = set; \
! s.sa_flags = 0; \
! sigaction((A), &s, (struct sigaction *) NULL); \
} while (0)
#endif
#ifndef my_pthread_setprio
--- 332,358 ----
#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
#endif
!
! /*
! We define my_sigset() and use that instead of the system sigset() so that
! we can favor an implementation based on sigaction(). On some systems, such
! as Mac OS X, sigset() results in flags such as SA_RESTART being set, and
! we want to make sure that no such flags are set.
! */
! #if defined(HAVE_SIGACTION) && !defined(my_sigset)
! #define my_sigset(A,B) do { struct sigaction s; sigset_t set; int rc; \
! DBUG_ASSERT((A) != 0); \
! sigemptyset(&set); \
! s.sa_handler = (B); \
! s.sa_mask = set; \
! s.sa_flags = 0; \
! rc= sigaction((A), &s, (struct sigaction *) NULL); \
! DBUG_ASSERT(rc == 0); \
} while (0)
+ #elif defined(HAVE_SIGSET) && !defined(my_sigset)
+ #define my_sigset(A,B) sigset((A),(B))
+ #elif !defined(my_sigset)
+ #define my_sigset(A,B) signal((A),(B))
#endif
#ifndef my_pthread_setprio
***************
*** 416,422 ****
#undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); }
#undef sigset
! #define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
#endif
#if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
--- 437,443 ----
#undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); }
#undef sigset
! #define my_sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
#endif
#if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
......@@ -24,11 +24,6 @@ extern "C" {
#ifndef USE_ALARM_THREAD
#define USE_ONE_SIGNAL_HAND /* One must call process_alarm */
#endif
#ifdef HAVE_LINUXTHREADS
#define THR_CLIENT_ALARM SIGALRM
#else
#define THR_CLIENT_ALARM SIGUSR1
#endif
#ifdef HAVE_rts_threads
#undef USE_ONE_SIGNAL_HAND
#define USE_ALARM_THREAD
......
......@@ -29,6 +29,8 @@
#define SCHED_POLICY SCHED_OTHER
#endif
uint thd_lib_detected;
#ifndef my_pthread_setprio
void my_pthread_setprio(pthread_t thread_id,int prior)
{
......@@ -335,7 +337,7 @@ void *sigwait_thread(void *set_arg)
sigaction(i, &sact, (struct sigaction*) 0);
}
}
sigaddset(set,THR_CLIENT_ALARM);
sigaddset(set, thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1);
pthread_sigmask(SIG_UNBLOCK,(sigset_t*) set,(sigset_t*) 0);
alarm_thread=pthread_self(); /* For thr_alarm */
......
......@@ -57,9 +57,7 @@ static void *alarm_handler(void *arg);
#define reschedule_alarms() pthread_kill(alarm_thread,THR_SERVER_ALARM)
#endif
#if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
static sig_handler thread_alarm(int sig __attribute__((unused)));
#endif
static int compare_ulong(void *not_used __attribute__((unused)),
byte *a_ptr,byte* b_ptr)
......@@ -78,9 +76,13 @@ 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 THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
my_sigset(THR_CLIENT_ALARM,thread_alarm);
#ifndef USE_ALARM_THREAD
if (thd_lib_detected != THD_LIB_LT)
#endif
{
my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
thread_alarm);
}
sigemptyset(&s);
sigaddset(&s, THR_SERVER_ALARM);
alarm_thread=pthread_self();
......@@ -98,10 +100,12 @@ void init_thr_alarm(uint max_alarms)
}
#elif defined(USE_ONE_SIGNAL_HAND)
pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */
#if THR_SERVER_ALARM == THR_CLIENT_ALARM
my_sigset(THR_CLIENT_ALARM,process_alarm); /* Linuxthreads */
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
#endif
if (thd_lib_detected == THD_LIB_LT)
{
my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
process_alarm); /* Linuxthreads */
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
}
#else
my_sigset(THR_SERVER_ALARM, process_alarm);
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
......@@ -152,7 +156,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
now=(ulong) time((time_t*) 0);
pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask);
pthread_mutex_lock(&LOCK_alarm); /* Lock from threads & alarms */
pthread_mutex_lock(&LOCK_alarm); /* Lock from threads & alarms */
if (alarm_aborted > 0)
{ /* No signal thread */
DBUG_PRINT("info", ("alarm aborted"));
......@@ -272,18 +276,18 @@ sig_handler process_alarm(int sig __attribute__((unused)))
This must be first as we can't call DBUG inside an alarm for a normal thread
*/
#if THR_SERVER_ALARM == THR_CLIENT_ALARM
if (!pthread_equal(pthread_self(),alarm_thread))
if (thd_lib_detected == THD_LIB_LT &&
!pthread_equal(pthread_self(),alarm_thread))
{
#if defined(MAIN) && !defined(__bsdi__)
printf("thread_alarm\n"); fflush(stdout);
printf("thread_alarm in process_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
my_sigset(THR_CLIENT_ALARM,process_alarm); /* int. thread system calls */
my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
process_alarm); /* int. thread system calls */
#endif
return;
}
#endif
/*
We have to do do the handling of the alarm in a sub function,
......@@ -327,7 +331,8 @@ 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, THR_CLIENT_ALARM))
pthread_kill(alarm_data->thread,
thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1))
{
#ifdef MAIN
printf("Warning: pthread_kill couldn't find thread!!!\n");
......@@ -351,7 +356,8 @@ 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, THR_CLIENT_ALARM))
pthread_kill(alarm_data->thread,
thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1))
{
#ifdef MAIN
printf("Warning: pthread_kill couldn't find thread!!!\n");
......@@ -488,7 +494,7 @@ void thr_alarm_info(ALARM_INFO *info)
ARGSUSED
*/
#if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
static sig_handler thread_alarm(int sig)
{
#ifdef MAIN
......@@ -498,7 +504,6 @@ static sig_handler thread_alarm(int sig)
my_sigset(sig,thread_alarm); /* int. thread system calls */
#endif
}
#endif
#ifdef HAVE_TIMESPEC_TS_SEC
......@@ -926,9 +931,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
sigaddset(&set,SIGINT);
sigaddset(&set,SIGQUIT);
sigaddset(&set,SIGTERM);
#if THR_CLIENT_ALARM != SIGHUP
sigaddset(&set,SIGHUP);
#endif
#ifdef SIGTSTP
sigaddset(&set,SIGTSTP);
#endif
......@@ -940,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,THR_CLIENT_ALARM);
THR_SERVER_ALARM, thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1);
DBUG_PRINT("info",("Starting signal and alarm handling thread"));
for(;;)
{
......@@ -1012,11 +1015,11 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
sigaddset(&set,SIGTSTP);
#endif
sigaddset(&set,THR_SERVER_ALARM);
sigdelset(&set,THR_CLIENT_ALARM);
sigdelset(&set, thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1);
(void) pthread_sigmask(SIG_SETMASK,&set,NULL);
#ifdef NOT_USED
sigemptyset(&set);
sigaddset(&set,THR_CLIENT_ALARM);
sigaddset(&set, thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1);
VOID(pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0));
#endif
#endif /* OS2 */
......@@ -1066,8 +1069,8 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
}
}
pthread_mutex_unlock(&LOCK_thread_count);
end_thr_alarm(1);
thr_alarm_info(&alarm_info);
end_thr_alarm(1);
printf("Main_thread: Alarms: %u max_alarms: %u next_alarm_time: %lu\n",
alarm_info.active_alarms, alarm_info.max_used_alarms,
alarm_info.next_alarm_time);
......
***************
*** 76,96 ****
alarm_aborted=0;
init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0,
compare_ulong,NullS);
! sigfillset(&full_signal_set); /* Neaded to block signals */
pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_alarm,NULL);
! #if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
! #if defined(HAVE_mit_thread)
! sigset(THR_CLIENT_ALARM,thread_alarm); /* int. thread system calls */
! #else
{
! struct sigaction sact;
! sact.sa_flags = 0;
! sact.sa_handler = thread_alarm;
! sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
}
- #endif
- #endif
sigemptyset(&s);
sigaddset(&s, THR_SERVER_ALARM);
alarm_thread=pthread_self();
--- 74,89 ----
alarm_aborted=0;
init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0,
compare_ulong,NullS);
! sigfillset(&full_signal_set); /* Needed to block signals */
pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_alarm,NULL);
! #ifndef USE_ALARM_THREAD
! if (thd_lib_detected != THD_LIB_LT)
! #endif
{
! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
! thread_alarm);
}
sigemptyset(&s);
sigaddset(&s, THR_SERVER_ALARM);
alarm_thread=pthread_self();
***************
*** 108,120 ****
}
#elif defined(USE_ONE_SIGNAL_HAND)
pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */
! #if THR_SERVER_ALARM == THR_CLIENT_ALARM
! sigset(THR_CLIENT_ALARM,process_alarm); /* Linuxthreads */
! pthread_sigmask(SIG_UNBLOCK, &s, NULL);
! #endif
#else
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
- sigset(THR_SERVER_ALARM,process_alarm);
#endif
DBUG_VOID_RETURN;
}
--- 101,115 ----
}
#elif defined(USE_ONE_SIGNAL_HAND)
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 */
! pthread_sigmask(SIG_UNBLOCK, &s, NULL);
! }
#else
+ my_sigset(THR_SERVER_ALARM, process_alarm);
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
#endif
DBUG_VOID_RETURN;
}
***************
*** 240,246 ****
if (alarm_data->malloced)
my_free((gptr) alarm_data,MYF(0));
found++;
! #ifndef DBUG_OFF
break;
#endif
}
--- 235,241 ----
if (alarm_data->malloced)
my_free((gptr) alarm_data,MYF(0));
found++;
! #ifdef DBUG_OFF
break;
#endif
}
***************
*** 249,258 ****
if (!found)
{
if (*alarmed)
! fprintf(stderr,"Warning: Didn't find alarm %lx in queue of %d alarms\n",
! (long) *alarmed, alarm_queue.elements);
! DBUG_PRINT("warning",("Didn't find alarm %lx in queue\n",
! (long) *alarmed));
}
pthread_mutex_unlock(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
--- 244,254 ----
if (!found)
{
if (*alarmed)
! fprintf(stderr,
! "Warning: Didn't find alarm 0x%lx in queue of %d alarms\n",
! (long) *alarmed, alarm_queue.elements);
! DBUG_PRINT("warning",("Didn't find alarm 0x%lx in queue\n",
! (long) *alarmed));
}
pthread_mutex_unlock(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
***************
*** 274,291 ****
This must be first as we can't call DBUG inside an alarm for a normal thread
*/
! #if THR_SERVER_ALARM == THR_CLIENT_ALARM
! if (!pthread_equal(pthread_self(),alarm_thread))
{
#if defined(MAIN) && !defined(__bsdi__)
! printf("thread_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
! sigset(THR_CLIENT_ALARM,process_alarm); /* int. thread system calls */
#endif
return;
}
- #endif
/*
We have to do do the handling of the alarm in a sub function,
--- 270,287 ----
This must be first as we can't call DBUG inside an alarm for a normal thread
*/
! if (thd_lib_detected == THD_LIB_LT &&
! !pthread_equal(pthread_self(),alarm_thread))
{
#if defined(MAIN) && !defined(__bsdi__)
! 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 */
#endif
return;
}
/*
We have to do do the handling of the alarm in a sub function,
***************
*** 301,307 ****
process_alarm_part2(sig);
#ifndef USE_ALARM_THREAD
#if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
! sigset(THR_SERVER_ALARM,process_alarm);
#endif
pthread_mutex_unlock(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
--- 297,303 ----
process_alarm_part2(sig);
#ifndef USE_ALARM_THREAD
#if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
! my_sigset(THR_SERVER_ALARM, process_alarm);
#endif
pthread_mutex_unlock(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
***************
*** 504,520 ****
ARGSUSED
*/
- #if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
static sig_handler thread_alarm(int sig)
{
#ifdef MAIN
printf("thread_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
! sigset(sig,thread_alarm); /* int. thread system calls */
#endif
}
- #endif
#ifdef HAVE_TIMESPEC_TS_SEC
--- 499,513 ----
ARGSUSED
*/
static sig_handler thread_alarm(int sig)
{
#ifdef MAIN
printf("thread_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
! my_sigset(sig, thread_alarm); /* int. thread system calls */
#endif
}
#ifdef HAVE_TIMESPEC_TS_SEC
***************
*** 915,921 ****
printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name());
fflush(stdout);
#ifdef DONT_REMEMBER_SIGNAL
! sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
#ifndef OS2
if (sig == SIGALRM)
--- 908,914 ----
printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name());
fflush(stdout);
#ifdef DONT_REMEMBER_SIGNAL
! my_sigset(sig, print_signal_warning); /* int. thread system calls */
#endif
#ifndef OS2
if (sig == SIGALRM)
......@@ -198,12 +198,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
......@@ -659,6 +653,7 @@ 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
/****************************************************************************
......@@ -698,7 +693,8 @@ 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,
thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1))
break; // allready dead
#endif
set_timespec(abstime, 2);
......@@ -2154,7 +2150,10 @@ static void init_signals(void)
DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT)
my_sigset(THR_KILL_SIGNAL,end_thread_signal);
{
my_sigset(thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2,
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))
......@@ -2211,8 +2210,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, thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2);
}
// For alarms
sigdelset(&set, thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1);
sigprocmask(SIG_SETMASK,&set,NULL);
pthread_sigmask(SIG_SETMASK,&set,NULL);
DBUG_VOID_RETURN;
......@@ -2276,23 +2279,19 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
*/
init_thr_alarm(max_connections +
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);
......@@ -3375,6 +3374,7 @@ 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,6 +7545,22 @@ 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)
{
......
***************
*** 177,188 ****
} /* cplusplus */
- #if defined(HAVE_LINUXTHREADS)
- #define THR_KILL_SIGNAL SIGINT
- #else
- #define THR_KILL_SIGNAL SIGUSR2 // Can't use this with LinuxThreads
- #endif
-
#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
#include <sys/types.h>
#else
--- 177,182 ----
} /* cplusplus */
#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
#include <sys/types.h>
#else
***************
*** 505,510 ****
static void clean_up_mutexes(void);
static int test_if_case_insensitive(const char *dir_name);
static void create_pid_file();
/****************************************************************************
** Code to end mysqld
--- 499,505 ----
static void clean_up_mutexes(void);
static int test_if_case_insensitive(const char *dir_name);
static void create_pid_file();
+ static uint get_thread_lib(void);
/****************************************************************************
** Code to end mysqld
***************
*** 544,550 ****
DBUG_PRINT("info",("Waiting for select_thread"));
#ifndef DONT_USE_THR_ALARM
! if (pthread_kill(select_thread,THR_CLIENT_ALARM))
break; // allready dead
#endif
set_timespec(abstime, 2);
--- 539,546 ----
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))
break; // allready dead
#endif
set_timespec(abstime, 2);
***************
*** 844,850 ****
sig,my_thread_id());
}
#ifdef DONT_REMEMBER_SIGNAL
! sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
if (sig == SIGALRM)
--- 840,846 ----
sig,my_thread_id());
}
#ifdef DONT_REMEMBER_SIGNAL
! my_sigset(sig, print_signal_warning); /* int. thread system calls */
#endif
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
if (sig == SIGALRM)
***************
*** 1841,1848 ****
DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT)
! sigset(THR_KILL_SIGNAL,end_thread_signal);
! sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
{
--- 1837,1847 ----
DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT)
! {
! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2,
! 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))
{
***************
*** 1877,1883 ****
#endif
(void) sigemptyset(&set);
#ifdef THREAD_SPECIFIC_SIGPIPE
! sigset(SIGPIPE,abort_thread);
sigaddset(&set,SIGPIPE);
#else
(void) signal(SIGPIPE,SIG_IGN); // Can't know which thread
--- 1876,1882 ----
#endif
(void) sigemptyset(&set);
#ifdef THREAD_SPECIFIC_SIGPIPE
! my_sigset(SIGPIPE, abort_thread);
sigaddset(&set,SIGPIPE);
#else
(void) signal(SIGPIPE,SIG_IGN); // Can't know which thread
***************
*** 2237,2244 ****
MY_INIT(argv[0]); // init my_sys library & pthreads
tzset(); // Set tzname
start_time=time((time_t*) 0);
-
#ifdef OS2
{
// fix timezone for daylight saving
--- 2236,2243 ----
MY_INIT(argv[0]); // init my_sys library & pthreads
tzset(); // Set tzname
+ thd_lib_detected= get_thread_lib();
start_time=time((time_t*) 0);
#ifdef OS2
{
// fix timezone for daylight saving
***************
*** 5547,5552 ****
(void) my_write(file, (byte*) buff, (uint) (end-buff),MYF(MY_WME));
(void) my_close(file, MYF(0));
}
}
--- 5546,5567 ----
(void) my_write(file, (byte*) buff, (uint) (end-buff),MYF(MY_WME));
(void) my_close(file, MYF(0));
}
+ }
+
+
+ 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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment