summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorunknown <jani@a88-113-38-195.elisa-laajakaista.fi>2007-01-22 02:32:07 +0200
committerunknown <jani@a88-113-38-195.elisa-laajakaista.fi>2007-01-22 02:32:07 +0200
commit454c763c6be44b34c8e1ff9b8561ab21e717b742 (patch)
tree48ef8f384e9e6131e128376bb19245a4cfec17c3 /include
parent7b2b2231a2df30198eb5dd4a35f7270dec5e5468 (diff)
downloadmariadb-git-454c763c6be44b34c8e1ff9b8561ab21e717b742.tar.gz
Fix for configure to detect library correctly.
Fix to check library in use during runtime. Fix for Bug#16995, "idle connections not being killed due to timeout when NPTL is used". BUILD/SETUP.sh: To avoid warnings during compilation. configure.in: Fixed configure so that it can correctly detect between NPTL and Linuxthreads. include/my_global.h: Fix for Linuxthreads. include/my_pthread.h: Added defines for different libraries that can be detected. Currently only 'other', 'nptl', and 'lt' (linuxthreads) are being used. changed sigset() and signal() to my_sigset() and my_signal() include/thr_alarm.h: Removed defines for Linuxthreads. This is now detected during runtime and handled in the thr_alarm.c mysys/my_pthread.c: Runtime check for library. mysys/thr_alarm.c: Runtime checks for library and corresponding signals. sql/mysqld.cc: Added function for detecting thread library in use during start-up. THR_KILL_SIGNAL removed, setting signals during runtime.
Diffstat (limited to 'include')
-rw-r--r--include/my_global.h7
-rw-r--r--include/my_pthread.h41
-rw-r--r--include/thr_alarm.h5
3 files changed, 36 insertions, 17 deletions
diff --git a/include/my_global.h b/include/my_global.h
index 37e53c65dec..e6bf9a9b840 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -97,7 +97,7 @@
/* Fix problem with S_ISLNK() on Linux */
-#if defined(HAVE_LINUXTHREADS)
+#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
#undef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
@@ -348,7 +348,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
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 7620b46e08b..e1a7ecab4ab 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -28,6 +28,14 @@
extern "C" {
#endif /* __cplusplus */
+/* Thread library */
+
+#define THD_LIB_OTHER 1
+#define THD_LIB_NPTL 2
+#define THD_LIB_LT 4
+
+extern uint thd_lib_detected;
+
#if defined(__WIN__) || defined(OS2)
#ifdef OS2
@@ -286,8 +294,8 @@ extern int my_pthread_create_detached;
#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_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,14 +332,27 @@ extern int my_pthread_cond_init(pthread_cond_t *mp,
#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); \
+
+/*
+ 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,7 +437,7 @@ struct tm *localtime_r(const time_t *clock, struct tm *res);
#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))
+#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)
diff --git a/include/thr_alarm.h b/include/thr_alarm.h
index 7a10d6886ce..0c26a67acf4 100644
--- a/include/thr_alarm.h
+++ b/include/thr_alarm.h
@@ -25,11 +25,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