summaryrefslogtreecommitdiff
path: root/mysys/thr_alarm.c
diff options
context:
space:
mode:
authorunknown <istruewing@chilla.local>2007-02-01 19:41:04 +0100
committerunknown <istruewing@chilla.local>2007-02-01 19:41:04 +0100
commitbaddc8bdca29b6e5dad37850ce3012cb60d0afa4 (patch)
treefad720adc8764e80870fde40bfd0a6b860c73aa5 /mysys/thr_alarm.c
parent42236fd910567a479ecdba513da5221a596f06be (diff)
parentcd4670a7aa270c655dd9a7a45d0c1e05b6f25dd0 (diff)
downloadmariadb-git-baddc8bdca29b6e5dad37850ce3012cb60d0afa4.tar.gz
Merge chilla.local:/home/mydev/mysql-5.0-axmrg
into chilla.local:/home/mydev/mysql-5.1-axmrg client/mysql.cc: Auto merged include/my_global.h: Auto merged include/thr_alarm.h: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/r/myisam.result: Auto merged mysql-test/r/ps.result: Auto merged mysql-test/r/symlink.result: Auto merged mysql-test/t/myisam.test: Auto merged mysql-test/t/ps.test: Auto merged mysql-test/t/symlink.test: Auto merged mysys/default.c: Auto merged mysys/my_pthread.c: Auto merged mysys/my_thr_init.c: Auto merged mysys/thr_alarm.c: Auto merged sql/field_conv.cc: Auto merged sql/gen_lex_hash.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/item_func.cc: Auto merged vio/viosslfactories.c: Auto merged BitKeeper/deleted/.del-mysqld.cc.rej: Delete: sql/mysqld.cc.rej BitKeeper/deleted/.del-my_create_tables.c~c121a0c4c427ebb: Auto merged BitKeeper/deleted/.del-my_manage.c~4de50e721d227d19: Auto merged BitKeeper/deleted/.del-my_manage.h~9d2cbc1e8bc894f: Auto merged BitKeeper/deleted/.del-mysql.dsw~7ea9e16395f139f4: Null merged BitKeeper/deleted/.del-mysql.sln~76a9ff1e793b3547: Null merged BitKeeper/deleted/.del-mysql_test_run_new.c~a23ab2c4b28b25ad: Auto merged BitKeeper/deleted/.del-mysql_test_run_new.dsp~9d8078f3f02fcc8e: Auto merged BitKeeper/deleted/.del-mysql_test_run_new.vcproj~1ddaed30361efefe: Auto merged BitKeeper/deleted/.del-mysql_test_run_new_ia64.dsp~e7ee71ec8d2995e3: Auto merged BUILD/SETUP.sh: Manual merged Makefile.am: Manual merged configure.in: Manual merged include/my_pthread.h: Manual merged mysql-test/Makefile.am: Manual merged sql/mysqld.cc: Manual merged support-files/mysql.spec.sh: Manual merged
Diffstat (limited to 'mysys/thr_alarm.c')
-rw-r--r--mysys/thr_alarm.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 170ee8a1b73..9c92333d1bd 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -34,6 +34,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;
@@ -56,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)
@@ -77,9 +76,16 @@ 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);
+ 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(thr_client_alarm, thread_alarm);
+ }
sigemptyset(&s);
sigaddset(&s, THR_SERVER_ALARM);
alarm_thread=pthread_self();
@@ -97,10 +103,11 @@ 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(thr_client_alarm, process_alarm); /* Linuxthreads */
+ pthread_sigmask(SIG_UNBLOCK, &s, NULL);
+ }
#else
my_sigset(THR_SERVER_ALARM, process_alarm);
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
@@ -151,7 +158,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"));
@@ -271,18 +278,17 @@ 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 in process_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
- my_sigset(THR_CLIENT_ALARM,process_alarm); /* int. thread system calls */
+ my_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,
@@ -326,7 +332,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, THR_CLIENT_ALARM))
+ pthread_kill(alarm_data->thread, thr_client_alarm))
{
#ifdef MAIN
printf("Warning: pthread_kill couldn't find thread!!!\n");
@@ -350,7 +356,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, THR_CLIENT_ALARM))
+ pthread_kill(alarm_data->thread, thr_client_alarm))
{
#ifdef MAIN
printf("Warning: pthread_kill couldn't find thread!!!\n");
@@ -487,7 +493,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
@@ -497,7 +503,6 @@ static sig_handler thread_alarm(int sig)
my_sigset(sig,thread_alarm); /* int. thread system calls */
#endif
}
-#endif
#ifdef HAVE_TIMESPEC_TS_SEC
@@ -783,9 +788,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
@@ -796,7 +799,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
puts("Starting signal handling thread");
#endif
printf("server alarm: %d thread alarm: %d\n",
- THR_SERVER_ALARM,THR_CLIENT_ALARM);
+ THR_SERVER_ALARM, thr_client_alarm);
DBUG_PRINT("info",("Starting signal and alarm handling thread"));
for(;;)
{
@@ -864,11 +867,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, thr_client_alarm);
(void) pthread_sigmask(SIG_SETMASK,&set,NULL);
#ifdef NOT_USED
sigemptyset(&set);
- sigaddset(&set,THR_CLIENT_ALARM);
+ sigaddset(&set, thr_client_alarm);
VOID(pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0));
#endif