control: Switch to using static instance of bus
Update main to use the static reference of the bus from
util::SDBusPlus.getBus() and have each object that needs the bus call
that same util::SDBusPlus.getBus() function to retrieve the same static
reference.
Change-Id: Icd5a0e61819bf1bec8b46daae05443fdcc542b05
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/main.cpp b/control/main.cpp
index 9170baf..1dcc0b5 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -33,7 +33,6 @@
int main(int argc, char* argv[])
{
auto event = sdeventplus::Event::get_default();
- auto bus = sdbusplus::bus::new_default();
#ifndef CONTROL_USE_JSON
phosphor::fan::util::ArgumentParser args(argc, argv);
@@ -62,14 +61,15 @@
// Attach the event object to the bus object so we can
// handle both sd_events (for the timers) and dbus signals.
- bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
+ phosphor::fan::util::SDBusPlus::getBus().attach_event(
+ event.get(), SD_EVENT_PRIORITY_NORMAL);
try
{
#ifdef CONTROL_USE_JSON
- json::Manager manager(bus, event);
+ json::Manager manager(event);
#else
- Manager manager(bus, event, mode);
+ Manager manager(phosphor::fan::util::SDBusPlus::getBus(), event, mode);
// Init mode will just set fans to max and delay
if (mode == Mode::init)