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:
parent
8da3ad4dde
commit
743785b563
2 changed files with 7 additions and 4 deletions
|
|
@ -422,8 +422,9 @@ namespace SimpleWeb {
|
||||||
std::shared_ptr<HTTP> socket(new HTTP(*io_service));
|
std::shared_ptr<HTTP> socket(new HTTP(*io_service));
|
||||||
|
|
||||||
acceptor->async_accept(*socket, [this, socket](const boost::system::error_code& ec){
|
acceptor->async_accept(*socket, [this, socket](const boost::system::error_code& ec){
|
||||||
//Immediately start accepting a new connection
|
//Immediately start accepting a new connection (if io_service hasn't been stopped)
|
||||||
accept();
|
if (ec != boost::asio::error::operation_aborted)
|
||||||
|
accept();
|
||||||
|
|
||||||
if(!ec) {
|
if(!ec) {
|
||||||
boost::asio::ip::tcp::no_delay option(true);
|
boost::asio::ip::tcp::no_delay option(true);
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,10 @@ namespace SimpleWeb {
|
||||||
std::shared_ptr<HTTPS> socket(new HTTPS(*io_service, context));
|
std::shared_ptr<HTTPS> socket(new HTTPS(*io_service, context));
|
||||||
|
|
||||||
acceptor->async_accept((*socket).lowest_layer(), [this, socket](const boost::system::error_code& ec) {
|
acceptor->async_accept((*socket).lowest_layer(), [this, socket](const boost::system::error_code& ec) {
|
||||||
//Immediately start accepting a new connection
|
//Immediately start accepting a new connection (if io_service hasn't been stopped)
|
||||||
accept();
|
if (ec != boost::asio::error::operation_aborted)
|
||||||
|
accept();
|
||||||
|
|
||||||
|
|
||||||
if(!ec) {
|
if(!ec) {
|
||||||
boost::asio::ip::tcp::no_delay option(true);
|
boost::asio::ip::tcp::no_delay option(true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue