Guard async transactions against spurious wakeups

This commit is contained in:
RipleyTom
2026-02-09 07:59:29 +02:00
committed by Elad
parent aeaa62a28c
commit 3bb21db71b
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -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;
}
+5 -2
View File
@@ -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;