dbushelper: avoid new bus connections
The dbushelper required a new bus connection, for what was often a
single dbus access. Switch the helper class to take a reference to
a bus instead so that the same bus connections can be reused.
Fixes openbmc/phosphor-pid-control#44
Tested: Significant decrease in the number of dbus connections
observed.
```
:1.510 8025 swampd root :1.510 phosphor-pid-control.service - -
:1.511 8025 swampd root :1.511 phosphor-pid-control.service - -
:1.512 8025 swampd root :1.512 phosphor-pid-control.service - -
xyz.openbmc_project.Hwmon.external 8025 swampd root :1.511 phosphor-pid-control.service - -
xyz.openbmc_project.State.FanCtrl 8025 swampd root :1.510 phosphor-pid-control.service
```
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ifbbfe10cbd533aa95e35db2800dfb9e83e37a5e0
diff --git a/dbus/dbushelper.hpp b/dbus/dbushelper.hpp
index 7d2be2d..9b73194 100644
--- a/dbus/dbushelper.hpp
+++ b/dbus/dbushelper.hpp
@@ -23,7 +23,8 @@
static constexpr char availabilityIntf[] =
"xyz.openbmc_project.State.Decorator.Availability";
- explicit DbusHelper(sdbusplus::bus_t bus) : _bus(std::move(bus)) {}
+ explicit DbusHelper(sdbusplus::bus_t& bus) : _bus(bus) {}
+ DbusHelper() = delete;
~DbusHelper() = default;
DbusHelper(const DbusHelper&) = delete;
@@ -70,7 +71,7 @@
}
private:
- sdbusplus::bus_t _bus;
+ sdbusplus::bus_t& _bus;
};
} // namespace pid_control