mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fix embedded/windows tests- move COND_manager and LOCK_manager to sql_manager.cc, to prevent race condition that results into accessing already destroyed critical section
This commit is contained in:
@ -44,6 +44,7 @@ static struct handler_cb * volatile cb_list;
|
||||
bool mysql_manager_submit(void (*action)())
|
||||
{
|
||||
bool result= FALSE;
|
||||
DBUG_ASSERT(manager_thread_in_use);
|
||||
struct handler_cb * volatile *cb;
|
||||
pthread_mutex_lock(&LOCK_manager);
|
||||
cb= &cb_list;
|
||||
@ -75,8 +76,9 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused)))
|
||||
|
||||
pthread_detach_this_thread();
|
||||
manager_thread = pthread_self();
|
||||
(void) pthread_cond_init(&COND_manager,NULL);
|
||||
(void) pthread_mutex_init(&LOCK_manager,NULL);
|
||||
manager_thread_in_use = 1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
pthread_mutex_lock(&LOCK_manager);
|
||||
@ -123,6 +125,8 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused)))
|
||||
}
|
||||
}
|
||||
manager_thread_in_use = 0;
|
||||
(void) pthread_mutex_destroy(&LOCK_manager);
|
||||
(void) pthread_cond_destroy(&COND_manager);
|
||||
DBUG_LEAVE; // Can't use DBUG_RETURN after my_thread_end
|
||||
my_thread_end();
|
||||
return (NULL);
|
||||
@ -149,14 +153,14 @@ void stop_handle_manager()
|
||||
{
|
||||
DBUG_ENTER("stop_handle_manager");
|
||||
abort_manager = true;
|
||||
pthread_mutex_lock(&LOCK_manager);
|
||||
if (manager_thread_in_use)
|
||||
{
|
||||
pthread_mutex_lock(&LOCK_manager);
|
||||
DBUG_PRINT("quit", ("initiate shutdown of handle manager thread: 0x%lx",
|
||||
(ulong)manager_thread));
|
||||
pthread_cond_signal(&COND_manager);
|
||||
pthread_cond_signal(&COND_manager);
|
||||
pthread_mutex_unlock(&LOCK_manager);
|
||||
}
|
||||
pthread_mutex_unlock(&LOCK_manager);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user