CPUSensor: Mark interface down when timeout

If we timeout it is because we cannot access the sensor.
Timeouts take a second, but with many sensors, they add
up. Mark the sensor failed the first time this
happens to boost the fans as soon as possible.

Tested: Fans boost after interface down

Change-Id: I753a3db65a24d45423998cb18bdcbc1f4147dbf4
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp
index 24e4de6..07f7ffd 100644
--- a/include/CPUSensor.hpp
+++ b/include/CPUSensor.hpp
@@ -46,6 +46,7 @@
     double dtsOffset;
     bool show;
     size_t pollTime;
+    bool loggedInterfaceDown = false;
     void setupRead(void);
     void handleResponse(const boost::system::error_code& err);
     void checkThresholds(void) override;
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 291d72f..127d68a 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -195,10 +195,26 @@
 
 void CPUSensor::handleResponse(const boost::system::error_code& err)
 {
+
     if (err == boost::system::errc::bad_file_descriptor)
     {
         return; // we're being destroyed
     }
+    else if (err == boost::system::errc::operation_canceled)
+    {
+        if (readingStateGood())
+        {
+            if (!loggedInterfaceDown)
+            {
+                std::cerr << name << " interface down!\n";
+                loggedInterfaceDown = true;
+            }
+            pollTime = 10000 + rand() % 10000;
+            markFunctional(false);
+        }
+        return;
+    }
+    loggedInterfaceDown = false;
     pollTime = CPUSensor::sensorPollMs;
     std::istream responseStream(&readBuf);
     if (!err)