introduce a max number of exceptions ignored in io_service main loop
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Mon, 12 Jan 2015 14:43:38 +0000 (15:43 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Mon, 12 Jan 2015 14:43:38 +0000 (15:43 +0100)
mainly for testing and debugging

src/main.cpp

index 34183ad..4ad6ce6 100644 (file)
@@ -446,6 +446,7 @@ int main( int argc, const char *argv[] )
     IoServiceItem io_service;
     int ret_code = 0;
     unsigned n_exceptions = 0;
+    unsigned max_exceptions = 1;
     try
     {
         ConfigurationItem configuration = get_configuration( argc, argv );
@@ -511,6 +512,14 @@ int main( int argc, const char *argv[] )
                 ++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;
+            }
         }
     }