| 8463 | |
| 8464 | |
| 8465 | void |
| 8466 | wait_for_commit::wakeup(int wakeup_error) |
| 8467 | { |
| 8468 | /* |
| 8469 | We signal each waiter on their own condition and mutex (rather than using |
| 8470 | pthread_cond_broadcast() or something like that). |
| 8471 | |
| 8472 | Otherwise we would need to somehow ensure that they were done |
| 8473 | waking up before we could allow this THD to be destroyed, which would |
| 8474 | be annoying and unnecessary. |
| 8475 | |
| 8476 | Note that wakeup_subsequent_commits2() depends on this function being a |
| 8477 | full memory barrier (it is, because it takes a mutex lock). |
| 8478 | |
| 8479 | */ |
| 8480 | mysql_mutex_lock(&LOCK_wait_commit); |
| 8481 | this->wakeup_error= wakeup_error; |
| 8482 | /* Memory barrier to make wakeup_error visible to the waiter thread. */ |
| 8483 | waitee.store(NULL, std::memory_order_release); |
| 8484 | /* |
| 8485 | Note that it is critical that the mysql_cond_signal() here is done while |
| 8486 | still holding the mutex. As soon as we release the mutex, the waiter might |
| 8487 | deallocate the condition object. |
| 8488 | */ |
| 8489 | mysql_cond_signal(&COND_wait_commit); |
| 8490 | mysql_mutex_unlock(&LOCK_wait_commit); |
| 8491 | } |
| 8492 | |
| 8493 | |
| 8494 | /* |
no test coverage detected