summaryrefslogtreecommitdiff
path: root/mysys/thr_alarm.c
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-10-11 09:12:12 -0700
committerunknown <jimw@mysql.com>2005-10-11 09:12:12 -0700
commite61dea1b3676844cf78e3cece5d5db1d4a0e847d (patch)
tree4607d81d45be27a727b93a40191ed4853e10f8ef /mysys/thr_alarm.c
parent78f5997adef773dfd5b05f6921b5da8066067c37 (diff)
downloadmariadb-git-e61dea1b3676844cf78e3cece5d5db1d4a0e847d.tar.gz
Fix wait_timeout (and kill) handling on Mac OS X by cleaning up how
signal handlers are set up, the blocking flags for sockets are set, and which thread-related functions are used. (Bug #8731) configure.in: Fix flags for Darwin 6 and later. Simplify Darwin 7-9 blocks to simply be a catch-all for *darwin* so that future Darwin releases get the latest flags. include/config-win.h: Define my_sigset() instead of sigset(). include/my_pthread.h: Define my_sigset() instead of trying to monkey with sigset(), and favor an implementation based on sigaction(). mysys/my_pthread.c: Remove pthread_signal(), which is identical to the new my_sigset() macro. mysys/thr_alarm.c: Use my_sigset() instead of sigset(). sql/mysqld.cc: Use my_sigset() instead of signal() and sigset(), remove unnecessary definition of sigset on __amiga__. Remove unused THREAD_SPECIFIC_SIGPIPE code. A future improvement would be to re-assess the use of sigaction() here and convert its usage to use my_sigset(). vio/vio.c: Always call fcntl() to initialize flags of socket in initialization to avoid problems on systems that don't report the flags on a socket correctly right after it has been returned from accept(), such as FreeBSD, Mac OS X, and possibly other BSD-derived systems. vio/viosocket.c: If fcntl() fails in vio_blocking(), restore the flags stored in the vio struct. mysql-test/r/wait_timeout.result: New BitKeeper file ``mysql-test/r/wait_timeout.result'' mysql-test/t/wait_timeout-master.opt: New BitKeeper file ``mysql-test/t/wait_timeout-master.opt'' mysql-test/t/wait_timeout.test: New BitKeeper file ``mysql-test/t/wait_timeout.test''
Diffstat (limited to 'mysys/thr_alarm.c')
-rw-r--r--mysys/thr_alarm.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 05d14073953..e5b77de5e38 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -80,17 +80,7 @@ void init_thr_alarm(uint max_alarms)
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;
- bzero((char*) &sact, sizeof(sact));
- sact.sa_handler = thread_alarm;
- sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
- }
-#endif
+ my_sigset(THR_CLIENT_ALARM,thread_alarm);
#endif
sigemptyset(&s);
sigaddset(&s, THR_SERVER_ALARM);
@@ -110,12 +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
- sigset(THR_CLIENT_ALARM,process_alarm); /* Linuxthreads */
+ my_sigset(THR_CLIENT_ALARM,process_alarm); /* Linuxthreads */
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
#endif
#else
+ my_sigset(THR_SERVER_ALARM, process_alarm);
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
- sigset(THR_SERVER_ALARM,process_alarm);
#endif
DBUG_VOID_RETURN;
}
@@ -290,7 +280,7 @@ sig_handler process_alarm(int sig __attribute__((unused)))
printf("thread_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
- sigset(THR_CLIENT_ALARM,process_alarm); /* int. thread system calls */
+ my_sigset(THR_CLIENT_ALARM,process_alarm); /* int. thread system calls */
#endif
return;
}
@@ -310,7 +300,7 @@ sig_handler process_alarm(int sig __attribute__((unused)))
process_alarm_part2(sig);
#ifndef USE_ALARM_THREAD
#if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
- sigset(THR_SERVER_ALARM,process_alarm);
+ my_sigset(THR_SERVER_ALARM,process_alarm);
#endif
pthread_mutex_unlock(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
@@ -512,7 +502,7 @@ static sig_handler thread_alarm(int sig)
printf("thread_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
- sigset(sig,thread_alarm); /* int. thread system calls */
+ my_sigset(sig,thread_alarm); /* int. thread system calls */
#endif
}
#endif
@@ -916,7 +906,7 @@ static sig_handler print_signal_warning(int sig)
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 */
+ my_sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
#ifndef OS2
if (sig == SIGALRM)