PingSchedulerList scheduler_list;
IoServiceItem io_service;
int ret_code = 0;
- unsigned n_exceptions = 0;
- unsigned max_exceptions = 0;
try
{
{
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;
}
}
}
GlobalLogger.notice() << "Pingcheck done " << endl;
- GlobalLogger.debug() << "In main loop, had " << n_exceptions << " exception[s]" << endl;
return ret_code;
}