Fixed crash if server instance gets deleted after the call to io_service->stop() but before the acceptor gets notified of the stop.

This commit is contained in:
David Olszowka 2016-11-07 17:32:21 +01:00 committed by eidheim
commit 743785b563
2 changed files with 7 additions and 4 deletions

View file

@ -422,8 +422,9 @@ namespace SimpleWeb {
std::shared_ptr<HTTP> socket(new HTTP(*io_service));
acceptor->async_accept(*socket, [this, socket](const boost::system::error_code& ec){
//Immediately start accepting a new connection
accept();
//Immediately start accepting a new connection (if io_service hasn't been stopped)
if (ec != boost::asio::error::operation_aborted)
accept();
if(!ec) {
boost::asio::ip::tcp::no_delay option(true);

View file

@ -31,8 +31,10 @@ namespace SimpleWeb {
std::shared_ptr<HTTPS> socket(new HTTPS(*io_service, context));
acceptor->async_accept((*socket).lowest_layer(), [this, socket](const boost::system::error_code& ec) {
//Immediately start accepting a new connection
accept();
//Immediately start accepting a new connection (if io_service hasn't been stopped)
if (ec != boost::asio::error::operation_aborted)
accept();
if(!ec) {
boost::asio::ip::tcp::no_delay option(true);