diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index c0cd1594e72..0faba93c0a3 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -1123,6 +1123,7 @@ static void wait_on_queue(KEYCACHE_WQUEUE *wqueue, struct st_my_thread_var *thread= my_thread_var; DBUG_ASSERT(!thread->next); DBUG_ASSERT(!thread->prev); /* Not required, but must be true anyway. */ + mysql_mutex_assert_owner(mutex); /* Add to queue. */ if (! (last= wqueue->last_thread)) @@ -1177,14 +1178,15 @@ static void release_whole_queue(KEYCACHE_WQUEUE *wqueue) do { thread=next; - DBUG_ASSERT(thread); + DBUG_ASSERT(thread && thread->init == 1); KEYCACHE_DBUG_PRINT("release_whole_queue: signal", ("thread %ld", thread->id)); + /* Take thread from queue. */ + next= thread->next; + thread->next= NULL; + /* Signal the thread. */ keycache_pthread_cond_signal(&thread->suspend); - /* Take thread from queue. */ - next=thread->next; - thread->next= NULL; } while (thread != last); diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index d9dbacc8524..1e4b85583b1 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -372,6 +372,8 @@ void my_thread_end(void) mysql_cond_signal(&THR_COND_threads); mysql_mutex_unlock(&THR_LOCK_threads); + /* Trash variable so that we can detect false accesses to my_thread_var */ + tmp->init= 2; TRASH(tmp, sizeof(*tmp)); free(tmp); }