wesnothd: don't let exceptions stop asio's event loop

Generally if we catch exception but continue the loop the player
associated with it would be automatically disconnected either due to
socket_ptr going out of scope or scope_exit calling remove_player().
This commit is contained in:
loonycyborg 2021-10-26 04:19:27 +03:00
parent fb2d03fdba
commit 8d06e6f223

View file

@ -227,11 +227,17 @@ void server_base::handle_termination(const boost::system::error_code& error, int
}
void server_base::run() {
try {
io_service_.run();
LOG_SERVER << "Server has shut down because event loop is out of work\n";
} catch(const server_shutdown& e) {
LOG_SERVER << "Server has been shut down: " << e.what() << "\n";
for(;;) {
try {
io_service_.run();
LOG_SERVER << "Server has shut down because event loop is out of work\n";
break;
} catch(const server_shutdown& e) {
LOG_SERVER << "Server has been shut down: " << e.what() << "\n";
break;
} catch(const std::exception& e) {
ERR_SERVER << "Caught exception from handler: " << e.what() << "\n";
}
}
}