decrement thead_count *after* THD is destroyed
because thread_count means just that: number of THDs and shutdown code looks at it to know when to free shared data structures that THD uses. This fixes random crashes in ~THD on shutdown
This commit is contained in:
parent
74aef87c5e
commit
7425610c81
@ -2972,7 +2972,6 @@ void unlink_thd(THD *thd)
|
||||
|
||||
unlink_not_visible_thd(thd);
|
||||
thd->free_connection();
|
||||
dec_thread_count();
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -3117,6 +3116,7 @@ bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
|
||||
if (!wsrep_applier && put_in_cache && cache_thread(thd))
|
||||
DBUG_RETURN(0); // Thread is reused
|
||||
delete thd;
|
||||
dec_thread_count();
|
||||
}
|
||||
|
||||
DBUG_PRINT("info", ("killing thread"));
|
||||
@ -6418,6 +6418,7 @@ void create_thread_to_handle_connection(CONNECT *connect)
|
||||
/* Get thread from cache */
|
||||
thread_cache.push_back(connect);
|
||||
wake_thread++;
|
||||
thread_safe_decrement32(&thread_count);
|
||||
mysql_cond_signal(&COND_thread_cache);
|
||||
mysql_mutex_unlock(&LOCK_thread_cache);
|
||||
DBUG_PRINT("info",("Thread created"));
|
||||
|
@ -39,6 +39,7 @@ static bool no_threads_end(THD *thd, bool put_in_cache)
|
||||
{
|
||||
unlink_thd(thd);
|
||||
delete thd;
|
||||
dec_thread_count();
|
||||
}
|
||||
return 1; // Abort handle_one_connection
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ void threadpool_remove_connection(THD *thd)
|
||||
close_connection(thd, 0);
|
||||
unlink_thd(thd);
|
||||
delete thd;
|
||||
mysql_cond_broadcast(&COND_thread_count);
|
||||
dec_thread_count();
|
||||
|
||||
/*
|
||||
Free resources associated with this connection:
|
||||
|
Loading…
x
Reference in New Issue
Block a user