Allow indefinite retries in tryRestartControlLoops()

On some platforms, when the BMC first starts up the sensors used in
swampd's PID loops may not yet exist, and may not start existing until
the host is first powered on.  Since that may not happen for an
arbitrarily long time, swampd can end up crashing after exhausting its
artificially-limited retry budget in tryRestartControlLoops(), at which
point it gets restarted by systemd and the loop continues.  Each time it
crashes we generate a warning in the Redfish event log though, which
isn't ideal since nothing truly erroneous has actually happened (aside
from the daemon somewhat spuriously dying).

With this change we instead allow tryRestartControlLoops() to retry
indefinitely without crashing the process, so that it can simply wait
until the sensors it's configured to use eventually appear.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I13f591fded2563731cb5a8c3a67283b57f99f6bf
diff --git a/main.cpp b/main.cpp
index bace238..5c26f01 100644
--- a/main.cpp
+++ b/main.cpp
@@ -169,17 +169,8 @@
 
 void tryRestartControlLoops(bool first)
 {
-    static int count = 0;
     static const auto delayTime = std::chrono::seconds(10);
     static boost::asio::steady_timer timer(io);
-    // try to start a control loop while the loop has been scheduled.
-    if (first && count != 0)
-    {
-        std::cerr
-            << "ControlLoops has been scheduled, refresh the loop count\n";
-        count = 1;
-        return;
-    }
 
     auto restartLbd = [](const boost::system::error_code& error) {
         if (error == boost::asio::error::operation_aborted)
@@ -187,31 +178,19 @@
             return;
         }
 
-        // for the last loop, don't elminate the failure of restartControlLoops.
-        if (count >= 5)
-        {
-            restartControlLoops();
-            // reset count after succesful restartControlLoops()
-            count = 0;
-            return;
-        }
-
         // retry when restartControlLoops() has some failure.
         try
         {
             restartControlLoops();
-            // reset count after succesful restartControlLoops()
-            count = 0;
         }
         catch (const std::exception& e)
         {
-            std::cerr << count
-                      << " Failed during restartControlLoops, try again: "
+            std::cerr << "Failed during restartControlLoops, try again: "
                       << e.what() << "\n";
             tryRestartControlLoops(false);
         }
     };
-    count++;
+
     // first time of trying to restart the control loop without a delay
     if (first)
     {