1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Make killing of threads safer

This commit is contained in:
monty@hundin.mysql.fi
2001-09-01 10:38:16 +03:00
parent e251f9d827
commit 7f4aee1c90
10 changed files with 36 additions and 45 deletions

View File

@ -482,7 +482,7 @@ public:
COPY_INFO info;
I_List<delayed_row> rows;
uint group_count;
TABLE_LIST *table_list; // Argument
TABLE_LIST table_list; // Argument
delayed_insert()
:locks_in_memory(0),
@ -611,7 +611,9 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
pthread_mutex_unlock(&LOCK_delayed_create);
DBUG_RETURN(0);
}
tmp->table_list=table_list; // Needed to open table
tmp->table_list= *table_list; // Needed to open table
tmp->table_list.db= tmp->thd.db;
tmp->table_list.name= tmp->table_list.real_name=tmp->thd.query;
tmp->lock();
pthread_mutex_lock(&tmp->mutex);
if ((error=pthread_create(&tmp->thd.real_id,&connection_attrib,
@ -846,11 +848,9 @@ void kill_delayed_threads(void)
pthread_mutex_lock(&tmp->thd.mysys_var->mutex);
if (tmp->thd.mysys_var->current_cond)
{
if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
pthread_mutex_lock(tmp->thd.mysys_var->current_mutex);
pthread_mutex_lock(tmp->thd.mysys_var->current_mutex);
pthread_cond_broadcast(tmp->thd.mysys_var->current_cond);
if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex);
pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex);
}
pthread_mutex_unlock(&tmp->thd.mysys_var->mutex);
}
@ -875,6 +875,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
thd->thread_id=thread_id++;
thd->end_time();
threads.append(thd);
thd->killed=abort_loop;
pthread_mutex_unlock(&LOCK_thread_count);
pthread_mutex_lock(&di->mutex);
@ -905,7 +906,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
/* open table */
if (!(di->table=open_ltable(thd,di->table_list,TL_WRITE_DELAYED)))
if (!(di->table=open_ltable(thd,&di->table_list,TL_WRITE_DELAYED)))
{
thd->fatal_error=1; // Abort waiting inserts
goto end;
@ -913,7 +914,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
if (di->table->file->has_transactions())
{
thd->fatal_error=1;
my_error(ER_ILLEGAL_HA, MYF(0), di->table_list->real_name);
my_error(ER_ILLEGAL_HA, MYF(0), di->table_list.real_name);
goto end;
}
di->table->copy_blobs=1;
@ -965,10 +966,8 @@ static pthread_handler_decl(handle_delayed_insert,arg)
#endif
/* Information for pthread_kill */
pthread_mutex_lock(&di->thd.mysys_var->mutex);
di->thd.mysys_var->current_mutex= &di->mutex;
di->thd.mysys_var->current_cond= &di->cond;
pthread_mutex_unlock(&di->thd.mysys_var->mutex);
di->thd.proc_info=0;
DBUG_PRINT("info",("Waiting for someone to insert rows"));
@ -996,10 +995,13 @@ static pthread_handler_decl(handle_delayed_insert,arg)
break;
}
}
/* We can't lock di->mutex and mysys_var->mutex at the same time */
pthread_mutex_unlock(&di->mutex);
pthread_mutex_lock(&di->thd.mysys_var->mutex);
di->thd.mysys_var->current_mutex= 0;
di->thd.mysys_var->current_cond= 0;
pthread_mutex_unlock(&di->thd.mysys_var->mutex);
pthread_mutex_lock(&di->mutex);
}
if (di->tables_in_use && ! thd->lock)