bus: Return the value of wait
Knowing the number of events being >0 is important if a timeout is set,
otherwise you can't know if processing is safe to perform.
Change-Id: Ifc3b8a01666422b4f2e057f0b162d7588c0ab446
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include/sdbusplus/bus.hpp b/include/sdbusplus/bus.hpp
index 2b7b1bd..c30d0d8 100644
--- a/include/sdbusplus/bus.hpp
+++ b/include/sdbusplus/bus.hpp
@@ -163,13 +163,19 @@
*
* @param[in] timeout_us - Timeout in usec.
*/
- void wait(uint64_t timeout_us)
+ int wait(uint64_t timeout_us)
{
- _intf->sd_bus_wait(_bus.get(), timeout_us);
+ int r = _intf->sd_bus_wait(_bus.get(), timeout_us);
+ if (r < 0)
+ {
+ throw exception::SdBusError(-r, "sd_bus_wait");
+ }
+ return r;
}
- void wait(std::optional<SdBusDuration> timeout = std::nullopt)
+
+ int wait(std::optional<SdBusDuration> timeout = std::nullopt)
{
- wait(timeout ? timeout->count() : UINT64_MAX);
+ return wait(timeout ? timeout->count() : UINT64_MAX);
}
/** @brief Process waiting dbus messages or signals. */