summaryrefslogtreecommitdiffstats
path: root/monitor
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 /monitor
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 'monitor')
-rw-r--r--monitor/Makefile.am2
-rw-r--r--monitor/fan.cpp4
-rw-r--r--monitor/fan.hpp6
-rw-r--r--monitor/main.cpp30
-rw-r--r--monitor/tach_sensor.cpp4
-rw-r--r--monitor/tach_sensor.hpp6
6 files changed, 17 insertions, 35 deletions
diff --git a/monitor/Makefile.am b/monitor/Makefile.am
index cb9b8a4..e8d9bbd 100644
--- a/monitor/Makefile.am
+++ b/monitor/Makefile.am
@@ -19,12 +19,14 @@ BUILT_SOURCES = fan_monitor_defs.cpp
phosphor_fan_monitor_LDADD = \
$(top_builddir)/libfan.la \
$(SDBUSPLUS_LIBS) \
+ $(SDEVENTPLUS_LIBS) \
$(PHOSPHOR_LOGGING_LIBS) \
${PHOSPHOR_DBUS_INTERFACES_LIBS} \
-lstdc++fs
phosphor_fan_monitor_CXXFLAGS = \
$(SDBUSPLUS_CFLAGS) \
+ $(SDEVENTPLUS_CFLAGS) \
$(PHOSPHOR_LOGGING_CFLAGS) \
${PHOSPHOR_DBUS_INTERFACES_CFLAGS} \
-flto
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 39b32bb..014080d 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -31,7 +31,7 @@ using namespace phosphor::logging;
Fan::Fan(Mode mode,
sdbusplus::bus::bus& bus,
- phosphor::fan::event::EventPtr& events,
+ const sdeventplus::Event& event,
std::unique_ptr<trust::Manager>& trust,
const FanDefinition& def) :
_bus(bus),
@@ -58,7 +58,7 @@ Fan::Fan(Mode mode,
std::get<factorField>(s),
std::get<offsetField>(s),
std::get<timeoutField>(def),
- events));
+ event));
_trustManager->registerSensor(_sensors.back());
}
diff --git a/monitor/fan.hpp b/monitor/fan.hpp
index fb87b66..663e27e 100644
--- a/monitor/fan.hpp
+++ b/monitor/fan.hpp
@@ -1,9 +1,9 @@
#pragma once
#include <sdbusplus/bus.hpp>
+#include <sdeventplus/event.hpp>
#include <tuple>
#include <vector>
-#include "event.hpp"
#include "tach_sensor.hpp"
#include "trust_manager.hpp"
#include "types.hpp"
@@ -78,13 +78,13 @@ class Fan
*
* @param mode - mode of fan monitor
* @param bus - the dbus object
- * @param events - pointer to sd_event object
+ * @param event - event loop reference
* @param trust - the tach trust manager
* @param def - the fan definition structure
*/
Fan(Mode mode,
sdbusplus::bus::bus& bus,
- phosphor::fan::event::EventPtr& events,
+ const sdeventplus::Event& event,
std::unique_ptr<trust::Manager>& trust,
const FanDefinition& def);
diff --git a/monitor/main.cpp b/monitor/main.cpp
index 512e3f7..cba3832 100644
--- a/monitor/main.cpp
+++ b/monitor/main.cpp
@@ -15,9 +15,8 @@
*/
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
-#include <systemd/sd-daemon.h>
+#include <sdeventplus/event.hpp>
#include "argument.hpp"
-#include "event.hpp"
#include "fan.hpp"
#include "fan_defs.hpp"
#include "trust_manager.hpp"
@@ -27,8 +26,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;
std::vector<std::unique_ptr<Fan>> fans;
phosphor::fan::util::ArgumentParser args(argc, argv);
@@ -53,22 +52,12 @@ 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;
- }
-
std::unique_ptr<phosphor::fan::trust::Manager> trust =
std::make_unique<phosphor::fan::trust::Manager>(trustGroups);
- 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);
for (const auto& fanDef : fanDefinitions)
{
@@ -83,7 +72,7 @@ int main(int argc, char* argv[])
}
}
fans.emplace_back(std::make_unique<Fan>(
- mode, bus, eventPtr, trust, fanDef));
+ mode, bus, event, trust, fanDef));
}
if (mode == Mode::init)
@@ -91,15 +80,6 @@ int main(int argc, char* argv[])
// Fans were initialized to be functional, exit
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 1;
+ return event.loop();
}
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 6789ed8..de1affb 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -76,7 +76,7 @@ TachSensor::TachSensor(Mode mode,
size_t factor,
size_t offset,
size_t timeout,
- phosphor::fan::event::EventPtr& events) :
+ const sdeventplus::Event& event) :
_bus(bus),
_fan(fan),
_name(FAN_SENSOR_PATH + id),
@@ -88,7 +88,7 @@ TachSensor::TachSensor(Mode mode,
_offset(offset),
_timeout(timeout),
_timerMode(TimerMode::func),
- _timer(events, [this, &fan](){ fan.timerExpired(*this); })
+ _timer(event, [this, &fan](){ fan.timerExpired(*this); })
{
// Start from a known state of functional
setFunctional(true);
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index f59f6f5..c46aa00 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -3,7 +3,7 @@
#include <chrono>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server.hpp>
-#include "event.hpp"
+#include <sdeventplus/event.hpp>
#include "timer.hpp"
namespace phosphor
@@ -78,7 +78,7 @@ class TachSensor
* @param[in] factor - the factor of the sensor target
* @param[in] offset - the offset of the sensor target
* @param[in] timeout - Normal timeout value to use
- * @param[in] events - sd_event pointer
+ * @param[in] event - Event loop reference
*/
TachSensor(Mode mode,
sdbusplus::bus::bus& bus,
@@ -90,7 +90,7 @@ class TachSensor
size_t factor,
size_t offset,
size_t timeout,
- phosphor::fan::event::EventPtr& events);
+ const sdeventplus::Event& event);
/**
* @brief Returns the target speed value
OpenPOWER on IntegriCloud