| 79 | } |
| 80 | |
| 81 | void local_acceptor_tcp_impl::async_accept(connection_handler _handler) { |
| 82 | std::scoped_lock const lock{mtx_}; |
| 83 | // tmp_socket is a `shared_ptr` due to the `std::function` below which requires everything to be copyable |
| 84 | std::shared_ptr<tcp_socket> tmp_socket = abstract_socket_factory::get()->create_tcp_socket(io_); |
| 85 | // Use the peer-endpoint overload so the remote address is captured by the kernel at accept() time. |
| 86 | // If the client disconnects immediately after connecting, calling remote_endpoint() on the socket |
| 87 | // in the callback would fail |
| 88 | auto tmp_remote_ep = std::make_shared<boost::asio::ip::tcp::endpoint>(); |
| 89 | acceptor_->async_accept(*tmp_socket, *tmp_remote_ep, |
| 90 | [weak_self = weak_from_this(), h = std::move(_handler), tmp_socket, tmp_remote_ep](auto const& _ec) { |
| 91 | if (auto self = weak_self.lock(); self) { |
| 92 | self->accept_cbk(_ec, std::move(h), tmp_socket, tmp_remote_ep); |
| 93 | } |
| 94 | }); |
| 95 | } |
| 96 | |
| 97 | // NOSONAR(cpp:S5213) - Handler is already std::function from async_accept, making this a template provides no benefit |
| 98 | void local_acceptor_tcp_impl::accept_cbk(boost::system::error_code const& _ec, connection_handler _handler, |
no test coverage detected