ipmi: use cv to wait async responses

This commit is contained in:
DH 2024-09-01 18:02:43 +03:00
parent 2c781626d3
commit 83ee2942fc
2 changed files with 11 additions and 7 deletions

View file

@ -71,6 +71,7 @@ struct IpmiClient : RcBase {
Ref<IpmiSession> session;
shared_mutex mutex;
shared_cv sessionCv;
shared_cv asyncResponseCv;
Process *process;
kdeque<MessageQueue> messageQueues;
kdeque<EventFlag> eventFlags;

View file

@ -504,13 +504,16 @@ orbis::SysResult orbis::sysImpiSessionRespondAsync(Thread *thread,
ORBIS_RET_ON_ERROR(ureadRaw(elem.data(), data.data, data.size));
}
std::lock_guard clientLock(client->mutex);
client->asyncResponses.push_back({
.methodId = _params.method,
.errorCode = _params.result,
.data = std::move(outData),
});
{
std::lock_guard clientLock(client->mutex);
client->asyncResponses.push_back({
.methodId = _params.method,
.errorCode = _params.result,
.data = std::move(outData),
});
}
client->asyncResponseCv.notify_all(client->mutex);
return uwrite(result, 0u);
}
@ -591,7 +594,7 @@ orbis::SysResult orbis::sysIpmiClientTryGetResult(Thread *thread,
}
}
std::this_thread::sleep_for(std::chrono::microseconds(200));
client->asyncResponseCv.wait(client->mutex);
}
// return uwrite(result, 0x80020000 + static_cast<int>(ErrorCode::AGAIN));