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>
diff --git a/mainloop.cpp b/mainloop.cpp
index 58806fb..d3987cc 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -567,9 +567,6 @@
// 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 @@
{
// 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 @@
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 @@
}
// 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