From 4f936a69a798483b318fad4124641256eb0ce380 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Oct 2003 20:55:15 +0300 Subject: Safety fix to detect multiple calls to my_thread_end() Portability fix (For Mac OS X) configure.in: Added detection of malloc / sys/malloc include/my_pthread.h: Safety fix to detect multiple calls to my_thread_end() libmysqld/lib_sql.cc: Remove duplicate call to my_thread_end() mysys/charset.c: Cleanup indentation Remove some short variable names mysys/my_thr_init.c: Safety fix to detect multiple calls to my_thread_end() sql/sql_test.cc: Portability fix (For Mac OS X) --- mysys/my_thr_init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'mysys/my_thr_init.c') diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 59466083b28..9f64e9dcb60 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -159,6 +159,7 @@ my_bool my_thread_init(void) tmp->id= ++thread_id; pthread_mutex_init(&tmp->mutex,MY_MUTEX_INIT_FAST); pthread_cond_init(&tmp->suspend, NULL); + tmp->init= 1; end: #if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) @@ -170,12 +171,14 @@ end: void my_thread_end(void) { - struct st_my_thread_var *tmp=my_thread_var; + struct st_my_thread_var *tmp; + tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); + #ifdef EXTRA_DEBUG_THREADS fprintf(stderr,"my_thread_end(): tmp=%p,thread_id=%ld\n", tmp,pthread_self()); #endif - if (tmp) + if (tmp && tmp->init) { #if !defined(DBUG_OFF) /* tmp->dbug is allocated inside DBUG library */ @@ -191,6 +194,8 @@ void my_thread_end(void) pthread_mutex_destroy(&tmp->mutex); #if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS) free(tmp); +#else + tmp->init= 0; #endif } /* The following free has to be done, even if my_thread_var() is 0 */ -- cgit v1.2.1