diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2018-03-26 09:55:19 -0500 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2018-04-13 14:33:41 +0000 |
commit | 33db92bc2ac5e345d5a42cae8ce48aa55d4dacef (patch) | |
tree | 9cd3968f3225594c8bd3ad4d3320068fe57b189f | |
parent | 31d214cc45ac505dfff4bb6405c70ff114e416b6 (diff) | |
download | phosphor-hwmon-33db92bc2ac5e345d5a42cae8ce48aa55d4dacef.tar.gz phosphor-hwmon-33db92bc2ac5e345d5a42cae8ce48aa55d4dacef.zip |
Include monitoring removed sensors for re-adding
When a sensor returns a defined return code causing it to be removed
during the monitoring loop, it should be re-added once the sensor is
successfully read not producing any of the defined return codes. Once
the sensor is re-added, it is erased from the removed list of sensors.
When a sensor continues to return a defined return code, it remains in
the removed sensor list and is attempted to be added after each
completion of the monitoring loop.
Tested:
Verify sensor is removed when return code received during monitoring
Sensor object added after successful read with no return codes
Change-Id: Id286d4b1f1e11e1148ad4182dd9726d3c348c9de
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r-- | mainloop.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/mainloop.cpp b/mainloop.cpp index 58806fb..d3987cc 100644 --- a/mainloop.cpp +++ b/mainloop.cpp @@ -567,9 +567,6 @@ void MainLoop::read() // TODO: Issue#3 - Need to make calls to the dbus sensor cache here to // ensure the objects all exist? - // Used in marking a sensor for removal from dbus - std::vector<SensorSet::key_type> destroy; - // Iterate through all the sensors. for (auto& i : state) { @@ -637,7 +634,7 @@ void MainLoop::read() { // Return code found in sensor removal list // Mark this sensor to be removed from dbus - destroy.push_back(i.first); + rmSensors[i.first] = std::get<0>(i.second); continue; } } @@ -661,7 +658,7 @@ void MainLoop::read() entry("FILE=%s", file.c_str())); #ifdef REMOVE_ON_FAIL - destroy.push_back(i.first); + rmSensors[i.first] = std::get<0>(i.second); #else exit(EXIT_FAILURE); #endif @@ -670,9 +667,9 @@ void MainLoop::read() } // Remove any sensors marked for removal - for (auto& i : destroy) + for (auto& i : rmSensors) { - state.erase(i); + state.erase(i.first); } #ifndef REMOVE_ON_FAIL |