Fix #245. Trying to keep serving after an exception in the handler.

This commit is contained in:
ipknHama 2017-09-17 12:44:15 +09:00
parent 2564c62778
commit 69a17f066b

View File

@ -121,12 +121,19 @@ namespace crow
timer.async_wait(handler);
init_count ++;
try
while(1)
{
io_service_pool_[i]->run();
} catch(std::exception& e)
{
CROW_LOG_ERROR << "Worker Crash: An uncaught exception occurred: " << e.what();
try
{
if (io_service_pool_[i]->run() == 0)
{
// when io_service.run returns 0, there are no more works to do.
break;
}
} catch(std::exception& e)
{
CROW_LOG_ERROR << "Worker Crash: An uncaught exception occurred: " << e.what();
}
}
}));