Allow removal from failsafe if timeout=0

Initialize cache on start adds all sensors to failsafe.
Without being able to hit the removal in updatesensors
this causes the system to go into failsafe and never
remove.

Closes #8

Change-Id: I83f495adb1475abc27dba1734022f28d89e03d8f
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/pid/zone.cpp b/pid/zone.cpp
index 4892409..fc0b40b 100644
--- a/pid/zone.cpp
+++ b/pid/zone.cpp
@@ -250,31 +250,25 @@
         _cachedValuesByName[t] = r.value;
         tstamp then = r.updated;
 
+        auto duration = duration_cast<std::chrono::seconds>(now - then).count();
+        auto period = std::chrono::seconds(timeout).count();
+
         if (sensor->getFailed())
         {
             _failSafeSensors.insert(t);
         }
-        /* Only go into failsafe if the timeout is set for
-         * the sensor.
-         */
-        else if (timeout > 0)
+        else if (timeout != 0 && duration >= period)
         {
-            auto duration =
-                duration_cast<std::chrono::seconds>(now - then).count();
-            auto period = std::chrono::seconds(timeout).count();
-            if (duration >= period)
+            // std::cerr << "Entering fail safe mode.\n";
+            _failSafeSensors.insert(t);
+        }
+        else
+        {
+            // Check if it's in there: remove it.
+            auto kt = _failSafeSensors.find(t);
+            if (kt != _failSafeSensors.end())
             {
-                // std::cerr << "Entering fail safe mode.\n";
-                _failSafeSensors.insert(t);
-            }
-            else
-            {
-                // Check if it's in there: remove it.
-                auto kt = _failSafeSensors.find(t);
-                if (kt != _failSafeSensors.end())
-                {
-                    _failSafeSensors.erase(kt);
-                }
+                _failSafeSensors.erase(kt);
             }
         }
     }