diff --git a/server_http.hpp b/server_http.hpp index 76f1be8..c274767 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -422,8 +422,9 @@ namespace SimpleWeb { std::shared_ptr 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); diff --git a/server_https.hpp b/server_https.hpp index 3478dec..67e7718 100644 --- a/server_https.hpp +++ b/server_https.hpp @@ -31,8 +31,10 @@ namespace SimpleWeb { std::shared_ptr 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);