mirror of
https://github.com/ARMSX2/ARMSX3.git
synced 2026-08-24 16:58:52 -07:00
Guard async transactions against spurious wakeups
This commit is contained in:
@@ -46,7 +46,7 @@ error_code generic_async_transaction_context::wait_for_completion()
|
||||
return *result;
|
||||
}
|
||||
|
||||
completion_cond.wait(lock);
|
||||
completion_cond.wait(lock, [this] { return result.has_value(); });
|
||||
|
||||
return *result;
|
||||
}
|
||||
|
||||
@@ -951,13 +951,16 @@ namespace np
|
||||
{
|
||||
thread_base::set_name("NP Trans Worker");
|
||||
|
||||
auto res = trans_ctx->wake_cond.wait_for(lock, std::chrono::microseconds(trans_ctx->timeout));
|
||||
bool has_value = trans_ctx->wake_cond.wait_for(lock, std::chrono::microseconds(trans_ctx->timeout), [&]
|
||||
{
|
||||
return trans_ctx->result.has_value();
|
||||
});
|
||||
{
|
||||
std::lock_guard lock_threads(this->mutex_async_transactions);
|
||||
this->async_transactions.erase(req_id);
|
||||
}
|
||||
|
||||
if (res == std::cv_status::timeout)
|
||||
if (!has_value)
|
||||
{
|
||||
trans_ctx->result = SCE_NP_COMMUNITY_ERROR_TIMEOUT;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user