summaryrefslogtreecommitdiff
path: root/mysys/my_thr_init.c
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-10-16 20:55:15 +0300
committerunknown <monty@mashka.mysql.fi>2003-10-16 20:55:15 +0300
commit4f936a69a798483b318fad4124641256eb0ce380 (patch)
tree15abb95c73d02f77be5ffd9d90398f905401d815 /mysys/my_thr_init.c
parent8ddb4b7c553508fbf48fb3026909a35bac98d32e (diff)
downloadmariadb-git-4f936a69a798483b318fad4124641256eb0ce380.tar.gz
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)
Diffstat (limited to 'mysys/my_thr_init.c')
-rw-r--r--mysys/my_thr_init.c9
1 files changed, 7 insertions, 2 deletions
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 */