summaryrefslogtreecommitdiff
path: root/mysys/my_thr_init.c
diff options
context:
space:
mode:
authorunknown <jani@ua141d10.elisa.omakaista.fi>2007-01-30 18:52:26 +0200
committerunknown <jani@ua141d10.elisa.omakaista.fi>2007-01-30 18:52:26 +0200
commitcdf6001aeb24d7085ab5f053b31858d95c382e06 (patch)
treebf4ddf26e334366c90958a67e6d3c8c1ad3c0cd6 /mysys/my_thr_init.c
parent454c763c6be44b34c8e1ff9b8561ab21e717b742 (diff)
downloadmariadb-git-cdf6001aeb24d7085ab5f053b31858d95c382e06.tar.gz
Cleanup of thread-type (linuxthread or NTPL) detection code
Move get_thread_lib to mysys/my_pthread.c Set 'thr_client_alarm' to signal number used by thr_alarm to give alarms include/my_global.h: Fixed to be same as in 5.1 include/my_pthread.h: Move things around to be more in line with rest of code mysys/default.c: Fixed two wrong pointer incrementations. mysys/my_pthread.c: Cleanup: Use variable thr_client_alarm mysys/my_thr_init.c: Detect thread library at startup. Set also thr_client_alarm signal here, so that we get it in init_signals() in mysqld mysys/thr_alarm.c: Set thr_client_alarm depending on which thread library we are using sql/mysqld.cc: Move get_thread_lib to mysys/my_pthread.c
Diffstat (limited to 'mysys/my_thr_init.c')
-rw-r--r--mysys/my_thr_init.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 878a861bc94..5729f27b7a7 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -21,6 +21,7 @@
#include "mysys_priv.h"
#include <m_string.h>
+#include <signal.h>
#ifdef THREAD
#ifdef USE_TLS
@@ -44,6 +45,8 @@ pthread_mutexattr_t my_fast_mutexattr;
pthread_mutexattr_t my_errchk_mutexattr;
#endif
+static uint get_thread_lib(void);
+
/*
initialize thread environment
@@ -57,6 +60,12 @@ pthread_mutexattr_t my_errchk_mutexattr;
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);
@@ -276,4 +285,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 */