Emulate sync D-Bus method call with async implementation underneath to avoid poll race condition

This commit is contained in:
sangelovic
2020-01-12 23:10:19 +01:00
parent cb118f95b7
commit 4688e81534
14 changed files with 760 additions and 592 deletions
+8
View File
@@ -652,6 +652,14 @@ MethodReply MethodCall::sendWithReply(uint64_t timeout) const
return Factory::create<MethodReply>(sdbusReply, sdbus_, adopt_message);
}
// TODO: Consider merging MethodCall with AsyncMethodCall (provide owning boolean parameter for no Slot),
// return sendWithReply and sendWithNoReply back as private methods.
void MethodCall::sendWithAsyncReply(void* callback, void* userData, uint64_t timeout) const
{
auto r = sdbus_->sd_bus_call_async(nullptr, nullptr, (sd_bus_message*)msg_, (sd_bus_message_handler_t)callback, userData, timeout);
SDBUS_THROW_ERROR_IF(r < 0, "Failed to call method with asynchronous reply", -r);
}
MethodReply MethodCall::sendWithNoReply() const
{
auto r = sdbus_->sd_bus_send(nullptr, (sd_bus_message*)msg_, nullptr);