summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-04-03 15:50:22 -0500
committerMatt Spinler <spinler@us.ibm.com>2018-04-13 14:33:41 +0000
commitd4beecfa33c1cd8ecc688ce472594284216cf541 (patch)
treefbb9b6316b245850382a45fe79712aff1e680cb1
parent8729e44a35e0b78c6119c769156cb46bd0987415 (diff)
downloadphosphor-hwmon-d4beecfa33c1cd8ecc688ce472594284216cf541.tar.gz
phosphor-hwmon-d4beecfa33c1cd8ecc688ce472594284216cf541.zip
No retries when adding a purposely removed sensor
When a sensor is removed due to a removal return code being received during a read, no read retries should be done when attempting to re-add it. This requires the sensor to be successful in its first read attempted when being re-added and keeps the re-adding of purposely removed sensors from consuming up to 1 second during the re-add attempt. Tested: A removed sensor is attempted to be read once on re-add Change-Id: Ia7eb463deb569c9d10883632e017b4dd05413854 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r--mainloop.cpp15
-rw-r--r--mainloop.hpp1
2 files changed, 12 insertions, 4 deletions
diff --git a/mainloop.cpp b/mainloop.cpp
index 8a804f7..c93beb8 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -207,7 +207,7 @@ int64_t adjustValue(const SensorSet::key_type& sensor, int64_t value)
}
auto addValue(const SensorSet::key_type& sensor,
- const std::string& devPath,
+ const RetryIO& retryIO,
sysfs::hwmonio::HwmonIO& ioAccess,
ObjectInfo& info,
bool isOCC = false)
@@ -232,8 +232,8 @@ auto addValue(const SensorSet::key_type& sensor,
sensor.first,
sensor.second,
hwmon::entry::cinput,
- sysfs::hwmonio::retries,
- sysfs::hwmonio::delay,
+ std::get<size_t>(retryIO),
+ std::get<std::chrono::milliseconds>(retryIO),
isOCC);
auto gain = getEnv("GAIN", sensor);
@@ -346,11 +346,18 @@ void MainLoop::getObject(SensorSet::container_t::const_reference sensor)
objectPath.append(label);
ObjectInfo info(&_bus, std::move(objectPath), Object());
+ RetryIO retryIO(sysfs::hwmonio::retries, sysfs::hwmonio::delay);
+ if (rmSensors.find(sensor.first) != rmSensors.end())
+ {
+ // When adding a sensor that was purposely removed,
+ // don't retry on errors when reading its value
+ std::get<size_t>(retryIO) = 0;
+ }
auto valueInterface = static_cast<
std::shared_ptr<ValueObject>>(nullptr);
try
{
- valueInterface = addValue(sensor.first, _devPath, ioAccess, info,
+ valueInterface = addValue(sensor.first, retryIO, ioAccess, info,
_isOCC);
}
catch (const std::system_error& e)
diff --git a/mainloop.hpp b/mainloop.hpp
index d1fe9b0..9a51580 100644
--- a/mainloop.hpp
+++ b/mainloop.hpp
@@ -14,6 +14,7 @@ static constexpr auto default_interval = 1000000;
using Object = std::map<InterfaceType, std::experimental::any>;
using ObjectInfo = std::tuple<sdbusplus::bus::bus*, std::string, Object>;
+using RetryIO = std::tuple<size_t, std::chrono::milliseconds>;
/** @class MainLoop
* @brief hwmon-readd main application loop.
OpenPOWER on IntegriCloud