| 1532 | */ |
| 1533 | |
| 1534 | static void debug_sync_execute(THD *thd, st_debug_sync_action *action) |
| 1535 | { |
| 1536 | #ifdef DBUG_TRACE |
| 1537 | const char *dsp_name= action->sync_point.c_ptr(); |
| 1538 | const char *sig_emit= action->signal.c_ptr(); |
| 1539 | const char *sig_wait= action->wait_for.c_ptr(); |
| 1540 | #endif |
| 1541 | DBUG_ENTER("debug_sync_execute"); |
| 1542 | DBUG_ASSERT(thd); |
| 1543 | DBUG_ASSERT(action); |
| 1544 | DBUG_PRINT("debug_sync", |
| 1545 | ("sync_point: '%s' activation_count: %lu hit_limit: %lu " |
| 1546 | "execute: %lu timeout: %lu signal: '%s' wait_for: '%s'", |
| 1547 | dsp_name, action->activation_count, action->hit_limit, |
| 1548 | action->execute, action->timeout, sig_emit, sig_wait)); |
| 1549 | |
| 1550 | DBUG_ASSERT(action->activation_count); |
| 1551 | action->activation_count--; |
| 1552 | |
| 1553 | if (action->execute) |
| 1554 | { |
| 1555 | const char *UNINIT_VAR(old_proc_info); |
| 1556 | |
| 1557 | action->execute--; |
| 1558 | |
| 1559 | /* |
| 1560 | If we will be going to wait, set proc_info for the PROCESSLIST table. |
| 1561 | Do this before emitting the signal, so other threads can see it |
| 1562 | if they awake before we enter_cond() below. |
| 1563 | */ |
| 1564 | if (action->wait_for.length()) |
| 1565 | { |
| 1566 | st_debug_sync_control *ds_control= thd->debug_sync_control; |
| 1567 | strxnmov(ds_control->ds_proc_info, sizeof(ds_control->ds_proc_info)-1, |
| 1568 | "debug sync point: ", action->sync_point.c_ptr(), NullS); |
| 1569 | old_proc_info= thd->proc_info; |
| 1570 | debug_sync_thd_proc_info(thd, ds_control->ds_proc_info); |
| 1571 | } |
| 1572 | |
| 1573 | /* |
| 1574 | Take mutex to ensure that only one thread access |
| 1575 | debug_sync_global.ds_signal at a time. Need to take mutex for |
| 1576 | read access too, to create a memory barrier in order to avoid that |
| 1577 | threads just reads an old cached version of the signal. |
| 1578 | */ |
| 1579 | |
| 1580 | mysql_mutex_lock(&debug_sync_global->ds_mutex); |
| 1581 | |
| 1582 | if (action->signal.length()) |
| 1583 | { |
| 1584 | int offset= 0, pos; |
| 1585 | bool error= false; |
| 1586 | |
| 1587 | /* This loop covers all signals in the list except for the last one. |
| 1588 | Split the signal string by commas and set a signal in the global |
| 1589 | variable for each one. */ |
| 1590 | while (!error && (pos= action->signal.strstr(",", 1, offset)) > 0) |
| 1591 | { |
no test coverage detected