diff options
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 54c3e91bcc3..7a89a3d38dd 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -868,6 +868,7 @@ void kill_delayed_threads(void) delayed_insert *tmp; while ((tmp=it++)) { + /* Ensure that the thread doesn't kill itself while we are looking at it */ pthread_mutex_lock(&tmp->mutex); tmp->thd.killed=1; if (tmp->thd.mysys_var) @@ -875,9 +876,15 @@ void kill_delayed_threads(void) pthread_mutex_lock(&tmp->thd.mysys_var->mutex); if (tmp->thd.mysys_var->current_cond) { - pthread_mutex_lock(tmp->thd.mysys_var->current_mutex); + /* + We need the following test because the main mutex may be locked + in handle_delayed_insert() + */ + if (&tmp->mutex != tmp->thd.mysys_var->current_mutex) + pthread_mutex_lock(tmp->thd.mysys_var->current_mutex); pthread_cond_broadcast(tmp->thd.mysys_var->current_cond); - pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex); + 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->mutex); } |