Added support in DEBUG_SYNC framework for actions when THD object isn't actively executed, that is when mysys_var == NULL

This commit is contained in:
Mikael Ronstrom 2010-11-09 16:33:40 +01:00
parent 414e92fb57
commit 2c40c11c83

View File

@ -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
{