removed the main while loop because if catch an exception cannot know state of pinger...
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Tue, 26 May 2015 08:09:50 +0000 (10:09 +0200)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Tue, 26 May 2015 08:09:50 +0000 (10:09 +0200)
src/main.cpp

index 72157ff..22273bc 100644 (file)
@@ -477,8 +477,6 @@ int main( int argc, const char *argv[] )
     PingSchedulerList scheduler_list;
     IoServiceItem io_service;
     int ret_code = 0;
-    unsigned n_exceptions = 0;
-    unsigned max_exceptions = 0;
 
     try
     {
@@ -558,51 +556,27 @@ int main( int argc, const char *argv[] )
     {
         GlobalLogger.error() << "Uncaught exception. " << ex.what() << endl;
         ret_code = 3;
-        ++n_exceptions;
     }
     catch (...) {
         GlobalLogger.error() << "Caught unknown exception!" << endl;
         ret_code = 4;
-        ++n_exceptions;
     }
 
     if ( ret_code == 0 )
     {
         GlobalLogger.info() << "starting io_service main loop" << endl;
 
-        if (max_exceptions > 0)
-            GlobalLogger.warning() << "Limited number of acceptable exceptions,"
-                                   << " this is a debugging option!";
-
         // call boost::asio main event loop, catching exceptions
-        while ( !signal_data.stopped )
+        try
+        {
+            io_service->run();
+        }
+        catch ( const std::exception &ex )
         {
-            try
-            {
-                io_service->run();
-            }
-            catch ( const std::exception &ex )
-            {
-                ++n_exceptions;
-                GlobalLogger.error() << "Caught exception, will continue. " << ex.what() << endl;
-            }
-            catch (...) {
-                ++n_exceptions;
-                GlobalLogger.error() << "Caught unknown exception, will continue!" << endl;
-            }
-
-            if (max_exceptions > 0 && n_exceptions >= max_exceptions)
-            {
-                GlobalLogger.info() << "reached max number of exceptions allowed in main loop" << endl;
-                io_service->stop();
-                signal_data.stopped = true;
-                break;
-            }
-            else if ( signal_data.stopped )
-                GlobalLogger.info() << "exiting io_service main loop" << endl;
-                // ( io_service->stop() has been called already in signal handler)
-            else
-                GlobalLogger.info() << "continuing io_service main loop" << endl;
+            GlobalLogger.error() << "Caught exception, will continue. " << ex.what() << endl;
+        }
+        catch (...) {
+            GlobalLogger.error() << "Caught unknown exception, will continue!" << endl;
         }
     }
 
@@ -624,6 +598,5 @@ int main( int argc, const char *argv[] )
     }
 
     GlobalLogger.notice() << "Pingcheck done " << endl;
-    GlobalLogger.debug() << "In main loop, had " << n_exceptions << " exception[s]" << endl;
     return ret_code;
 }