summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysys/my_init.c5
-rw-r--r--mysys/my_thr_init.c1
-rw-r--r--mysys/waiting_threads.c6
3 files changed, 10 insertions, 2 deletions
diff --git a/mysys/my_init.c b/mysys/my_init.c
index c16602318ca..14f831f72b2 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -29,6 +29,7 @@
#pragma comment(lib, "ws2_32")
#endif
my_bool have_tcpip=0;
+extern pthread_key(struct st_my_thread_var*, THR_KEY_mysys);
static void my_win_init(void);
static my_bool win32_init_tcp_ip();
#else
@@ -221,7 +222,9 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
if (have_tcpip)
WSACleanup();
#endif /* __WIN__ */
-
+
+ /* At very last, delete mysys key, it is used everywhere including DBUG */
+ pthread_key_delete(THR_KEY_mysys);
my_init_done=0;
} /* my_end */
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 03041342787..ac16189f3a7 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -274,7 +274,6 @@ void my_thread_global_end(void)
*/
if (all_threads_killed)
{
- pthread_key_delete(THR_KEY_mysys);
my_thread_destroy_internal_mutex();
}
my_thread_global_init_done= 0;
diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c
index ddc06a3ae5e..f7e74e012d2 100644
--- a/mysys/waiting_threads.c
+++ b/mysys/waiting_threads.c
@@ -423,6 +423,8 @@ static void wt_resource_destroy(uchar *arg)
DBUG_VOID_RETURN;
}
+static int wt_init_done;
+
void wt_init()
{
DBUG_ENTER("wt_init");
@@ -456,18 +458,22 @@ void wt_init()
my_atomic_rwlock_init(&cycle_stats_lock);
my_atomic_rwlock_init(&success_stats_lock);
my_atomic_rwlock_init(&wait_stats_lock);
+ wt_init_done= 1;
DBUG_VOID_RETURN;
}
void wt_end()
{
DBUG_ENTER("wt_end");
+ if (!wt_init_done)
+ DBUG_VOID_RETURN;
DBUG_ASSERT(reshash.count == 0);
lf_hash_destroy(&reshash);
my_atomic_rwlock_destroy(&cycle_stats_lock);
my_atomic_rwlock_destroy(&success_stats_lock);
my_atomic_rwlock_destroy(&wait_stats_lock);
+ wt_init_done= 0;
DBUG_VOID_RETURN;
}