| 61 | } |
| 62 | |
| 63 | void server::do_accept() |
| 64 | { |
| 65 | // The newly accepted socket is put into its own strand to ensure that all |
| 66 | // completion handlers associated with the connection do not run concurrently. |
| 67 | acceptor_.async_accept(boost::asio::make_strand(io_context_), |
| 68 | [this](boost::system::error_code ec, boost::asio::ip::tcp::socket socket) |
| 69 | { |
| 70 | // Check whether the server was stopped by a signal before this |
| 71 | // completion handler had a chance to run. |
| 72 | if (!acceptor_.is_open()) |
| 73 | { |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | if (!ec) |
| 78 | { |
| 79 | std::make_shared<connection>( |
| 80 | std::move(socket), request_handler_)->start(); |
| 81 | } |
| 82 | |
| 83 | do_accept(); |
| 84 | }); |
| 85 | } |
| 86 | |
| 87 | void server::do_await_stop() |
| 88 | { |
nothing calls this directly
no test coverage detected