summaryrefslogtreecommitdiffstats
path: root/control/main.cpp
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-10-19 17:29:46 -0700
committerWilliam A. Kennington III <wak@google.com>2018-10-29 15:59:03 -0700
commit1cfc2f11b13412a15f8478cebc35e50e6feb13a2 (patch)
tree05986154355a3d6c0667368c12cf34d7ad97d4cd /control/main.cpp
parent5882e0c0593edaf464eea960f1ab7b2f5cd10240 (diff)
downloadphosphor-fan-presence-1cfc2f11b13412a15f8478cebc35e50e6feb13a2.tar.gz
phosphor-fan-presence-1cfc2f11b13412a15f8478cebc35e50e6feb13a2.zip
Switch sd_event loops to sdeventplus
This change is mostly focused around plumbing the sdeventplus::Event object everywhere and using the member functions provided for the event. No migration to the timer utility is performed yet. Change-Id: I912ab82bc081239d3b7c3cf7c5caca6742ef9c87 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'control/main.cpp')
-rw-r--r--control/main.cpp29
1 files changed, 6 insertions, 23 deletions
diff --git a/control/main.cpp b/control/main.cpp
index 8c13cf9..4420488 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -14,10 +14,10 @@
* limitations under the License.
*/
#include <sdbusplus/bus.hpp>
+#include <sdeventplus/event.hpp>
#include <phosphor-logging/log.hpp>
#include "argument.hpp"
#include "manager.hpp"
-#include "event.hpp"
#include "sdbusplus.hpp"
using namespace phosphor::fan::control;
@@ -25,8 +25,8 @@ using namespace phosphor::logging;
int main(int argc, char* argv[])
{
+ auto event = sdeventplus::Event::get_default();
auto bus = sdbusplus::bus::new_default();
- sd_event* events = nullptr;
phosphor::fan::util::ArgumentParser args(argc, argv);
if (argc != 2)
@@ -51,23 +51,13 @@ int main(int argc, char* argv[])
return 1;
}
- auto r = sd_event_default(&events);
- if (r < 0)
- {
- log<level::ERR>("Failed call to sd_event_default()",
- entry("ERROR=%s", strerror(-r)));
- return 1;
- }
-
- phosphor::fan::event::EventPtr eventPtr{events};
-
//Attach the event object to the bus object so we can
//handle both sd_events (for the timers) and dbus signals.
- bus.attach_event(eventPtr.get(), SD_EVENT_PRIORITY_NORMAL);
+ bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
try
{
- Manager manager(bus, eventPtr, mode);
+ Manager manager(bus, event, mode);
//Init mode will just set fans to max and delay
if (mode == Mode::init)
@@ -75,15 +65,8 @@ int main(int argc, char* argv[])
manager.doInit();
return 0;
}
- else
- {
- r = sd_event_loop(eventPtr.get());
- if (r < 0)
- {
- log<level::ERR>("Failed call to sd_event_loop",
- entry("ERROR=%s", strerror(-r)));
- }
- }
+
+ return event.loop();
}
//Log the useful metadata on these exceptions and let the app
//return 1 so it is restarted without a core dump.
OpenPOWER on IntegriCloud