Use a single dbus connection object
Starting with sdbusplus 8ca6025, calling bus_new_default multiple times
doesn't seem to work - making calls that generate dbus traffic on one
of the objects results in something like:
sd_bus_call: System.Error.ENOTCONN: Transport endpoint is not connected
This wasn't ideal anyway - move to a single object, shared
application-wide.
Tested: Booted a witherspoon QEMU image and there were no coredumps
Change-Id: I804a1b1438b22f48e45b26d395135e401ca98a06
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/settings.cpp b/settings.cpp
index aeefe64..9add59d 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -15,9 +15,8 @@
constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
-Objects::Objects()
+Objects::Objects(sdbusplus::bus::bus& bus) : bus(bus)
{
- auto bus = sdbusplus::bus::new_default();
std::vector<std::string> settingsIntfs = {timeOwnerIntf, timeSyncIntf,
hostStateIntf};
auto depth = 0;
@@ -71,7 +70,6 @@
Service Objects::service(const Path& path, const Interface& interface) const
{
- auto bus = sdbusplus::bus::new_default();
using Interfaces = std::vector<Interface>;
auto mapperCall =
bus.new_method_call(mapperService, mapperPath, mapperIntf, "GetObject");