From 2c40c11c8359b12d7c3e4d498c0fb18730d73f92 Mon Sep 17 00:00:00 2001 From: Mikael Ronstrom Date: Tue, 9 Nov 2010 16:33:40 +0100 Subject: [PATCH] Added support in DEBUG_SYNC framework for actions when THD object isn't actively executed, that is when mysys_var == NULL --- sql/debug_sync.cc | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index 74e5b2c70f3..1390bac8352 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -1746,10 +1746,15 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) mutex and cond. This would prohibit the use of DEBUG_SYNC between other places of enter_cond() and exit_cond(). */ - old_mutex= thd->mysys_var->current_mutex; - old_cond= thd->mysys_var->current_cond; - thd->mysys_var->current_mutex= &debug_sync_global.ds_mutex; - thd->mysys_var->current_cond= &debug_sync_global.ds_cond; + if (thd->mysys_var) + { + old_mutex= thd->mysys_var->current_mutex; + old_cond= thd->mysys_var->current_cond; + thd->mysys_var->current_mutex= &debug_sync_global.ds_mutex; + thd->mysys_var->current_cond= &debug_sync_global.ds_cond; + } + else + old_mutex= NULL; set_timespec(abstime, action->timeout); DBUG_EXECUTE("debug_sync_exec", { @@ -1804,11 +1809,16 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) is locked. (See comment in THD::exit_cond().) */ mysql_mutex_unlock(&debug_sync_global.ds_mutex); - mysql_mutex_lock(&thd->mysys_var->mutex); - thd->mysys_var->current_mutex= old_mutex; - thd->mysys_var->current_cond= old_cond; - thd_proc_info(thd, old_proc_info); - mysql_mutex_unlock(&thd->mysys_var->mutex); + if (old_mutex) + { + mysql_mutex_lock(&thd->mysys_var->mutex); + thd->mysys_var->current_mutex= old_mutex; + thd->mysys_var->current_cond= old_cond; + thd_proc_info(thd, old_proc_info); + mysql_mutex_unlock(&thd->mysys_var->mutex); + } + else + thd_proc_info(thd, old_proc_info); } else {