Don't use deprecated asio functions
This code used a number of asio functions that have been deprecated.
This patch replaces them with their new equivalents, and enabled
BOOST_ASIO_NO_DEPRECATED.
Change-Id: I98bddba4c7d72a53ceca9455429828e60f06c5e0
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index 3f9089f..3c95a41 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -108,7 +108,7 @@
// prior to reading a value at least for one scan cycle to get a valid
// value. Guarantee that the HW signal can be stable, the HW signal
// could be instability.
- waitTimer.expires_from_now(
+ waitTimer.expires_after(
std::chrono::milliseconds(bridgeGpio->setupTimeMs));
waitTimer.async_wait(
[weakRef, buffer](const boost::system::error_code& ec) {
@@ -198,7 +198,7 @@
return; // we're no longer valid
}
inputDev.assign(fd);
- waitTimer.expires_from_now(std::chrono::milliseconds(sensorPollMs));
+ waitTimer.expires_after(std::chrono::milliseconds(sensorPollMs));
waitTimer.async_wait([weakRef](const boost::system::error_code& ec) {
std::shared_ptr<ADCSensor> self = weakRef.lock();
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index d7f1b2d..4987f1f 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -308,7 +308,7 @@
auto sensorsChanged =
std::make_shared<boost::container::flat_set<std::string>>();
- io.post([&]() {
+ boost::asio::post(io, [&]() {
createSensors(io, objectServer, sensors, systemBus, nullptr,
UpdateType::init);
});
@@ -323,7 +323,7 @@
}
sensorsChanged->insert(message.get_path());
// this implicitly cancels the timer
- filterTimer.expires_from_now(std::chrono::seconds(1));
+ filterTimer.expires_after(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
@@ -374,7 +374,7 @@
}
// this implicitly cancels the timer
- cpuFilterTimer.expires_from_now(std::chrono::seconds(1));
+ cpuFilterTimer.expires_after(std::chrono::seconds(1));
cpuFilterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/ChassisIntrusionSensor.cpp b/src/ChassisIntrusionSensor.cpp
index 44ce3ac..5bff6db 100644
--- a/src/ChassisIntrusionSensor.cpp
+++ b/src/ChassisIntrusionSensor.cpp
@@ -147,7 +147,7 @@
void ChassisIntrusionSensor::pollSensorStatusByPch()
{
// setting a new experation implicitly cancels any pending async wait
- mPollTimer.expires_from_now(std::chrono::seconds(intrusionSensorPollSec));
+ mPollTimer.expires_after(std::chrono::seconds(intrusionSensorPollSec));
mPollTimer.async_wait([&](const boost::system::error_code& ec) {
// case of timer expired
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 8808ac8..9beae58 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -939,13 +939,14 @@
std::shared_ptr<ExitAirTempSensor> sensor =
nullptr; // wait until we find the config
- io.post([&]() { createSensor(objectServer, sensor, systemBus); });
+ boost::asio::post(io,
+ [&]() { createSensor(objectServer, sensor, systemBus); });
boost::asio::steady_timer configTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t&) {
- configTimer.expires_from_now(std::chrono::seconds(1));
+ configTimer.expires_after(std::chrono::seconds(1));
// create a timer because normally multiple properties change
configTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/ExternalSensorMain.cpp b/src/ExternalSensorMain.cpp
index 627a4f6..2c10dc8 100644
--- a/src/ExternalSensorMain.cpp
+++ b/src/ExternalSensorMain.cpp
@@ -350,7 +350,8 @@
std::make_shared<boost::container::flat_set<std::string>>();
boost::asio::steady_timer reaperTimer(io);
- io.post([&objectServer, &sensors, &systemBus, &reaperTimer]() {
+ boost::asio::post(io,
+ [&objectServer, &sensors, &systemBus, &reaperTimer]() {
createSensors(objectServer, sensors, systemBus, nullptr, reaperTimer);
});
@@ -373,7 +374,7 @@
}
// this implicitly cancels the timer
- filterTimer.expires_from_now(std::chrono::seconds(1));
+ filterTimer.expires_after(std::chrono::seconds(1));
filterTimer.async_wait(
[&objectServer, &sensors, &systemBus, &sensorsChanged,
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index 2756213..5042fb6 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -556,7 +556,7 @@
auto sensorsChanged =
std::make_shared<boost::container::flat_set<std::string>>();
- io.post([&]() {
+ boost::asio::post(io, [&]() {
createSensors(io, objectServer, tachSensors, pwmSensors, systemBus,
nullptr);
});
@@ -571,7 +571,7 @@
}
sensorsChanged->insert(message.get_path());
// this implicitly cancels the timer
- filterTimer.expires_from_now(std::chrono::seconds(1));
+ filterTimer.expires_after(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index 28f191b..340bf11 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -663,7 +663,7 @@
};
setupPowerMatchCallback(systemBus, powerCallBack);
- io.post([&]() {
+ boost::asio::post(io, [&]() {
createSensors(io, objectServer, sensors, systemBus, nullptr, false);
});
@@ -677,7 +677,7 @@
}
sensorsChanged->insert(message.get_path());
// this implicitly cancels the timer
- filterTimer.expires_from_now(std::chrono::seconds(1));
+ filterTimer.expires_after(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 9fdbab1..180c0c8 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -142,7 +142,7 @@
void HwmonTempSensor::restartRead()
{
std::weak_ptr<HwmonTempSensor> weakRef = weak_from_this();
- waitTimer.expires_from_now(std::chrono::milliseconds(sensorPollMs));
+ waitTimer.expires_after(std::chrono::milliseconds(sensorPollMs));
waitTimer.async_wait([weakRef](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/IntelCPUSensor.cpp b/src/IntelCPUSensor.cpp
index 9cd0409..fa26332 100644
--- a/src/IntelCPUSensor.cpp
+++ b/src/IntelCPUSensor.cpp
@@ -114,7 +114,7 @@
void IntelCPUSensor::restartRead(void)
{
std::weak_ptr<IntelCPUSensor> weakRef = weak_from_this();
- waitTimer.expires_from_now(std::chrono::milliseconds(pollTime));
+ waitTimer.expires_after(std::chrono::milliseconds(pollTime));
waitTimer.async_wait([weakRef](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/IntelCPUSensorMain.cpp b/src/IntelCPUSensorMain.cpp
index f0b5f8c..d1c5a0e 100644
--- a/src/IntelCPUSensorMain.cpp
+++ b/src/IntelCPUSensorMain.cpp
@@ -552,8 +552,7 @@
if (rescanDelaySeconds != 0U)
{
- creationTimer.expires_from_now(
- std::chrono::seconds(rescanDelaySeconds));
+ creationTimer.expires_after(std::chrono::seconds(rescanDelaySeconds));
creationTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
@@ -584,7 +583,7 @@
boost::container::flat_set<CPUConfig>& cpuConfigs,
ManagedObjectType& sensorConfigs)
{
- pingTimer.expires_from_now(std::chrono::seconds(1));
+ pingTimer.expires_after(std::chrono::seconds(1));
pingTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
@@ -714,7 +713,7 @@
boost::asio::steady_timer filterTimer(io);
ManagedObjectType sensorConfigs;
- filterTimer.expires_from_now(std::chrono::seconds(1));
+ filterTimer.expires_after(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
@@ -742,7 +741,7 @@
}
// this implicitly cancels the timer
- filterTimer.expires_from_now(std::chrono::seconds(1));
+ filterTimer.expires_after(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index cdb6551..a76457d 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -22,7 +22,6 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
-#include <sdbusplus/asio/sd_event.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
#include <sdbusplus/exception.hpp>
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index b939ff1..3ac42ac 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -404,7 +404,7 @@
void IpmbSensor::read(void)
{
- waitTimer.expires_from_now(std::chrono::milliseconds(sensorPollMs));
+ waitTimer.expires_after(std::chrono::milliseconds(sensorPollMs));
waitTimer.async_wait(
[weakRef{weak_from_this()}](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
@@ -645,7 +645,7 @@
}
// we seem to send this command too fast sometimes, wait before
// sending
- initCmdTimer->expires_from_now(
+ initCmdTimer->expires_after(
std::chrono::seconds(reinitWaitSeconds));
initCmdTimer->async_wait([](const boost::system::error_code ec) {
@@ -677,13 +677,14 @@
initCmdTimer = std::make_unique<boost::asio::steady_timer>(io);
- io.post([&]() { createSensors(io, objectServer, sensors, systemBus); });
+ boost::asio::post(
+ io, [&]() { createSensors(io, objectServer, sensors, systemBus); });
boost::asio::steady_timer configTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t&) {
- configTimer.expires_from_now(std::chrono::seconds(1));
+ configTimer.expires_after(std::chrono::seconds(1));
// create a timer because normally multiple properties change
configTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/MCUTempSensor.cpp b/src/MCUTempSensor.cpp
index cf38521..304034d 100644
--- a/src/MCUTempSensor.cpp
+++ b/src/MCUTempSensor.cpp
@@ -154,7 +154,7 @@
{
static constexpr size_t pollTime = 1; // in seconds
- waitTimer.expires_from_now(std::chrono::seconds(pollTime));
+ waitTimer.expires_after(std::chrono::seconds(pollTime));
waitTimer.async_wait([this](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
@@ -266,13 +266,14 @@
systemBus->request_name("xyz.openbmc_project.MCUTempSensor");
- io.post([&]() { createSensors(io, objectServer, sensors, systemBus); });
+ boost::asio::post(
+ io, [&]() { createSensors(io, objectServer, sensors, systemBus); });
boost::asio::steady_timer configTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t&) {
- configTimer.expires_from_now(std::chrono::seconds(1));
+ configTimer.expires_after(std::chrono::seconds(1));
// create a timer because normally multiple properties change
configTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/NVMeBasicContext.cpp b/src/NVMeBasicContext.cpp
index 3bf315a..0bc2252 100644
--- a/src/NVMeBasicContext.cpp
+++ b/src/NVMeBasicContext.cpp
@@ -352,7 +352,7 @@
{
pollCursor = sensors.begin();
- scanTimer.expires_from_now(std::chrono::seconds(1));
+ scanTimer.expires_after(std::chrono::seconds(1));
scanTimer.async_wait([weakSelf{weak_from_this()}](
const boost::system::error_code errorCode) {
if (errorCode == boost::asio::error::operation_aborted)
diff --git a/src/NVMeSensorMain.cpp b/src/NVMeSensorMain.cpp
index f331747..ef1abbe 100644
--- a/src/NVMeSensorMain.cpp
+++ b/src/NVMeSensorMain.cpp
@@ -235,13 +235,14 @@
sdbusplus::asio::object_server objectServer(systemBus, true);
objectServer.add_manager("/xyz/openbmc_project/sensors");
- io.post([&]() { createSensors(io, objectServer, systemBus); });
+ boost::asio::post(io,
+ [&]() { createSensors(io, objectServer, systemBus); });
boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&filterTimer, &io, &objectServer, &systemBus](sdbusplus::message_t&) {
// this implicitly cancels the timer
- filterTimer.expires_from_now(std::chrono::seconds(1));
+ filterTimer.expires_after(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/PSUEvent.cpp b/src/PSUEvent.cpp
index 1dd98ca..a065158 100644
--- a/src/PSUEvent.cpp
+++ b/src/PSUEvent.cpp
@@ -220,7 +220,7 @@
void PSUSubEvent::restartRead()
{
std::weak_ptr<PSUSubEvent> weakRef = weak_from_this();
- waitTimer.expires_from_now(std::chrono::milliseconds(eventPollMs));
+ waitTimer.expires_after(std::chrono::milliseconds(eventPollMs));
waitTimer.async_wait([weakRef](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/PSUSensor.cpp b/src/PSUSensor.cpp
index 049ae5c..763a926 100644
--- a/src/PSUSensor.cpp
+++ b/src/PSUSensor.cpp
@@ -146,7 +146,7 @@
void PSUSensor::restartRead(void)
{
std::weak_ptr<PSUSensor> weakRef = weak_from_this();
- waitTimer.expires_from_now(std::chrono::milliseconds(sensorPollMs));
+ waitTimer.expires_after(std::chrono::milliseconds(sensorPollMs));
waitTimer.async_wait([weakRef](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index a9db462..4007103 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -1059,7 +1059,7 @@
propertyInitialize();
- io.post([&]() { createSensors(io, objectServer, systemBus, nullptr); });
+ boost::asio::post(io, [&]() { createSensors(io, objectServer, systemBus, nullptr); });
boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
@@ -1069,7 +1069,7 @@
return;
}
sensorsChanged->insert(message.get_path());
- filterTimer.expires_from_now(std::chrono::seconds(3));
+ filterTimer.expires_after(std::chrono::seconds(3));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index 0462186..3971324 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -126,7 +126,7 @@
void TachSensor::restartRead(size_t pollTime)
{
std::weak_ptr<TachSensor> weakRef = weak_from_this();
- waitTimer.expires_from_now(std::chrono::milliseconds(pollTime));
+ waitTimer.expires_after(std::chrono::milliseconds(pollTime));
waitTimer.async_wait([weakRef](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index aa73063..5f56ae2 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -348,7 +348,7 @@
pair->first.level = threshold.level;
pair->first.direction = threshold.direction;
pair->first.assert = assert;
- pair->second.expires_from_now(std::chrono::seconds(waitTime));
+ pair->second.expires_after(std::chrono::seconds(waitTime));
pair->second.async_wait([weakSensor, pair, threshold, assert,
assertValue](boost::system::error_code ec) {
auto sensorPtr = weakSensor.lock();