bus/process: Implement error handling for sd_bus_process calls
This improves error coverage to make sure we aren't silently ignoring
errors when processing incoming sd_bus messages.
Tested:
Builds for zaius and boots successfully from a cold boot and through
a host reboot.
Change-Id: I045ce4c31c0e5580d8fa1329136a1963bb0dd0a5
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/sdbusplus/bus.hpp.in b/sdbusplus/bus.hpp.in
index a0f21ed..11bacd3 100644
--- a/sdbusplus/bus.hpp.in
+++ b/sdbusplus/bus.hpp.in
@@ -161,7 +161,11 @@
auto process()
{
sd_bus_message* m = nullptr;
- _intf->sd_bus_process(_bus.get(), &m);
+ int r = _intf->sd_bus_process(_bus.get(), &m);
+ if (r < 0)
+ {
+ throw exception::SdBusError(-r, "sd_bus_process");
+ }
return message::message(m, _intf, std::false_type());
}
@@ -170,7 +174,11 @@
*/
void process_discard()
{
- _intf->sd_bus_process(_bus.get(), nullptr);
+ int r = _intf->sd_bus_process(_bus.get(), nullptr);
+ if (r < 0)
+ {
+ throw exception::SdBusError(-r, "sd_bus_process discard");
+ }
}
/** @brief Claim a service name on the dbus.