diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-12-18 18:13:12 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-12-19 13:38:46 +0000 |
commit | 4e84539349dac086ce2a58e5b9900ed4e40a2eaf (patch) | |
tree | 1b5f3655927b8c5c1685179acddbe82927ac3980 | |
parent | 37539dcc2b8c735d03a7c2840ad9ae04180da142 (diff) | |
download | phosphor-time-manager-4e84539349dac086ce2a58e5b9900ed4e40a2eaf.tar.gz phosphor-time-manager-4e84539349dac086ce2a58e5b9900ed4e40a2eaf.zip |
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>
-rw-r--r-- | manager.cpp | 2 | ||||
-rw-r--r-- | settings.cpp | 4 | ||||
-rw-r--r-- | settings.hpp | 10 |
3 files changed, 9 insertions, 7 deletions
diff --git a/manager.cpp b/manager.cpp index f9de91d..69639e4 100644 --- a/manager.cpp +++ b/manager.cpp @@ -30,7 +30,7 @@ using namespace phosphor::logging; const std::set<std::string> Manager::managedProperties = {PROPERTY_TIME_MODE, PROPERTY_TIME_OWNER}; -Manager::Manager(sdbusplus::bus::bus& bus) : bus(bus) +Manager::Manager(sdbusplus::bus::bus& bus) : bus(bus), settings(bus) { using namespace sdbusplus::bus::match::rules; hostStateChangeMatch = diff --git a/settings.cpp b/settings.cpp index aeefe64..9add59d 100644 --- a/settings.cpp +++ b/settings.cpp @@ -15,9 +15,8 @@ constexpr auto mapperService = "xyz.openbmc_project.ObjectMapper"; 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 @@ Objects::Objects() 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"); diff --git a/settings.hpp b/settings.hpp index 8a89e74..b4893cb 100644 --- a/settings.hpp +++ b/settings.hpp @@ -25,9 +25,10 @@ struct Objects * * @param[in] bus - The D-bus bus object */ - Objects(); - Objects(const Objects&) = default; - Objects& operator=(const Objects&) = default; + Objects() = delete; + explicit Objects(sdbusplus::bus::bus&); + Objects(const Objects&) = delete; + Objects& operator=(const Objects&) = delete; Objects(Objects&&) = default; Objects& operator=(Objects&&) = default; ~Objects() = default; @@ -51,6 +52,9 @@ struct Objects /** @brief host state object */ Path hostState; + + private: + sdbusplus::bus::bus& bus; }; } // namespace settings |