summaryrefslogtreecommitdiff
path: root/mysys/my_thr_init.c
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2011-12-02 15:35:05 +0100
committerVladislav Vaintroub <wlad@montyprogram.com>2011-12-02 15:35:05 +0100
commitc4f5908a799e0b6ddcdc44f9957b5f99aaf40fd6 (patch)
tree8945418a6db73395e8a8136b49084d553dda51e9 /mysys/my_thr_init.c
parent970bc8cd0bd01073899a3f371cbe1ad3d0cf2057 (diff)
downloadmariadb-git-c4f5908a799e0b6ddcdc44f9957b5f99aaf40fd6.tar.gz
Fixed crashes found by application verifier:
- leaking mutex in lf_hash_destroy - pthread_getspecific() before pthread_key_create() in my_thread_var_dbug() (called by static C++ object constructors called in sys_vars) - perfschema destroys mutexes that were not created.
Diffstat (limited to 'mysys/my_thr_init.c')
-rw-r--r--mysys/my_thr_init.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index e2e03cc37a8..a2d34225e32 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -228,7 +228,6 @@ void my_thread_global_end(void)
}
mysql_mutex_unlock(&THR_LOCK_threads);
- pthread_key_delete(THR_KEY_mysys);
mysql_mutex_destroy(&THR_LOCK_malloc);
mysql_mutex_destroy(&THR_LOCK_open);
mysql_mutex_destroy(&THR_LOCK_lock);
@@ -246,7 +245,7 @@ void my_thread_global_end(void)
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
mysql_mutex_destroy(&LOCK_localtime_r);
#endif
-
+ pthread_key_delete(THR_KEY_mysys);
my_thread_global_init_done= 0;
}
@@ -429,8 +428,10 @@ const char *my_thread_name(void)
extern void **my_thread_var_dbug()
{
- struct st_my_thread_var *tmp=
- my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
+ struct st_my_thread_var *tmp;
+ if (!my_thread_global_init_done)
+ return NULL;
+ tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
return tmp && tmp->init ? &tmp->dbug : 0;
}
#endif /* DBUG_OFF */
@@ -439,8 +440,10 @@ extern void **my_thread_var_dbug()
safe_mutex_t **my_thread_var_mutex_in_use()
{
- struct st_my_thread_var *tmp=
- my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
+ struct st_my_thread_var *tmp;
+ if (!my_thread_global_init_done)
+ return NULL;
+ tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
return tmp ? &tmp->mutex_in_use : 0;
}