From 0d788b1e91e77b50bcd03359ad052f4795ae1c09 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Sep 2000 19:37:07 +0300 Subject: Fix for SAFE_MUTEX on windows Docs/manual.texi: cleanup include/my_pthread.h: Fix for SAFEMUTEX under windows mysys/my_thr_init.c: Fix for SAFEMUTEX under windows mysys/my_winthread.c: Fix for SAFEMUTEX under windows mysys/thr_mutex.c: Fix for SAFEMUTEX under windows sql/mysqld.cc: Remove unused code sql/sql_table.cc: Fix filename comparison on Windows support-files/Makefile.am: Added magic file --- mysys/my_thr_init.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'mysys/my_thr_init.c') diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index d879da8e65d..6b75444f3fc 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -77,10 +77,19 @@ void my_thread_global_end(void) static long thread_id=0; +/* + We can't use mutex_locks here if we re using windows as + we may have compiled the program with SAFE_MUTEX, in which + case the checking of mutex_locks will not work until + the pthread_self thread specific variable is initialized. +*/ + my_bool my_thread_init(void) { struct st_my_thread_var *tmp; +#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) pthread_mutex_lock(&THR_LOCK_lock); +#endif #if !defined(__WIN__) || defined(USE_TLS) if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys)) { @@ -98,9 +107,11 @@ my_bool my_thread_init(void) pthread_setspecific(THR_KEY_mysys,tmp); #else - if (THR_KEY_mysys.id) /* Allready initialized */ + if (THR_KEY_mysys.id) /* Already initialized */ { +#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) pthread_mutex_unlock(&THR_LOCK_lock); +#endif return 0; } tmp= &THR_KEY_mysys; @@ -108,7 +119,9 @@ my_bool my_thread_init(void) tmp->id= ++thread_id; pthread_mutex_init(&tmp->mutex,NULL); pthread_cond_init(&tmp->suspend, NULL); +#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) pthread_mutex_unlock(&THR_LOCK_lock); +#endif return 0; } -- cgit v1.2.1