diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2018-04-02 12:41:26 -0500 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2018-04-13 14:33:41 +0000 |
commit | 38c74e70d98d5dc9f106868252ea8afd0787430b (patch) | |
tree | 77d8f28a333090cdb8d0d440c9cddedab9274625 | |
parent | 28f8e66dd50d5c855ddf0ea02f2eef56ec0274fc (diff) | |
download | phosphor-hwmon-38c74e70d98d5dc9f106868252ea8afd0787430b.tar.gz phosphor-hwmon-38c74e70d98d5dc9f106868252ea8afd0787430b.zip |
Trace return code driven remove/add of sensors
A review comment request was to trace to the journal each time a
sensor is removed given a return code for removal and when that sensor
is re-added.
Request->https://gerrit.openbmc-project.xyz/#/c/9823/2/mainloop.cpp
Tested:
Verify journal entry created when sensor is removed
Verify journal entry created when sensor is re-added
Change-Id: I258bc98da7970080771762717f6a9383f4c68942
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r-- | mainloop.cpp | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/mainloop.cpp b/mainloop.cpp index 29ce2b3..8a804f7 100644 --- a/mainloop.cpp +++ b/mainloop.cpp @@ -355,6 +355,11 @@ void MainLoop::getObject(SensorSet::container_t::const_reference sensor) } catch (const std::system_error& e) { + auto file = sysfs::make_sysfs_path( + ioAccess.path(), + sensor.first.first, + sensor.first.second, + hwmon::entry::cinput); #ifndef REMOVE_ON_FAIL // Check sensorAdjusts for sensor removal RCs const auto& it = sensorAdjusts.find(sensor.first); @@ -363,9 +368,16 @@ void MainLoop::getObject(SensorSet::container_t::const_reference sensor) auto rmRCit = it->second.rmRCs.find(e.code().value()); if (rmRCit != std::end(it->second.rmRCs)) { - // Return code found in sensor removal list - // Skip adding this sensor for now - rmSensors[std::move(sensor.first)] = std::move(sensor.second); + // Return code found in sensor return code removal list + if (rmSensors.find(sensor.first) == rmSensors.end()) + { + // Trace for sensor not already removed from dbus + log<level::INFO>("Sensor not added to dbus for read fail", + entry("FILE=%s", file.c_str()), + entry("RC=%d", e.code().value())); + rmSensors[std::move(sensor.first)] = + std::move(sensor.second); + } return; } } @@ -378,12 +390,6 @@ void MainLoop::getObject(SensorSet::container_t::const_reference sensor) xyz::openbmc_project::Sensor::Device:: ReadFailure::CALLOUT_DEVICE_PATH(_devPath.c_str())); - auto file = sysfs::make_sysfs_path( - ioAccess.path(), - sensor.first.first, - sensor.first.second, - hwmon::entry::cinput); - log<level::INFO>("Logging failing sysfs file", entry("FILE=%s", file.c_str())); #ifdef REMOVE_ON_FAIL @@ -588,6 +594,11 @@ void MainLoop::read() } catch (const std::system_error& e) { + auto file = sysfs::make_sysfs_path( + ioAccess.path(), + i.first.first, + i.first.second, + hwmon::entry::cinput); #ifndef REMOVE_ON_FAIL // Check sensorAdjusts for sensor removal RCs const auto& it = sensorAdjusts.find(i.first); @@ -596,9 +607,17 @@ void MainLoop::read() auto rmRCit = it->second.rmRCs.find(e.code().value()); if (rmRCit != std::end(it->second.rmRCs)) { - // Return code found in sensor removal list - // Mark this sensor to be removed from dbus - rmSensors[i.first] = std::get<0>(i.second); + // Return code found in sensor return code removal list + if (rmSensors.find(i.first) == rmSensors.end()) + { + // Trace for sensor not already removed from dbus + log<level::INFO>( + "Remove sensor from dbus for read fail", + entry("FILE=%s", file.c_str()), + entry("RC=%d", e.code().value())); + // Mark this sensor to be removed from dbus + rmSensors[i.first] = std::get<0>(i.second); + } continue; } } @@ -612,12 +631,6 @@ void MainLoop::read() ReadFailure::CALLOUT_DEVICE_PATH( _devPath.c_str())); - auto file = sysfs::make_sysfs_path( - ioAccess.path(), - i.first.first, - i.first.second, - hwmon::entry::cinput); - log<level::INFO>("Logging failing sysfs file", entry("FILE=%s", file.c_str())); @@ -649,6 +662,14 @@ void MainLoop::read() if (state.find(it->first) != state.end()) { // Sensor object added, erase entry from removal list + auto file = sysfs::make_sysfs_path( + ioAccess.path(), + it->first.first, + it->first.second, + hwmon::entry::cinput); + log<level::INFO>( + "Added sensor to dbus after successful read", + entry("FILE=%s", file.c_str())); it = rmSensors.erase(it); } else |