NOSONAR(cpp:S5213) - Handler is already std::function from async_accept, making this a template provides no benefit
| 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, |
| 99 | std::shared_ptr<tcp_socket> _socket, std::shared_ptr<boost::asio::ip::tcp::endpoint> _remote_ep) { |
| 100 | if (_ec) { |
| 101 | _handler(_ec, nullptr); |
| 102 | return; |
| 103 | } |
| 104 | std::unique_lock lock{mtx_}; |
| 105 | // transfer ownership of the socket member, subsequent async_accept calls will re-instantiate it |
| 106 | auto socket = |
| 107 | std::make_shared<local_socket_tcp_impl>(io_, std::move(_socket), local_ep_, std::move(*_remote_ep), socket_role_e::SERVER); |
| 108 | socket->set_socket_options(*configuration_); |
| 109 | lock.unlock(); |
| 110 | // invoke handler only without the lock (avoids the need of a recursive mutex) |
| 111 | _handler(_ec, std::move(socket)); |
| 112 | } |
| 113 | |
| 114 | port_t local_acceptor_tcp_impl::get_local_port() { |
| 115 | std::scoped_lock const lock{mtx_}; |
no test coverage detected