diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl index 1aa081b23e..ac88ef86a8 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.inl +++ b/contrib/epee/include/net/abstract_tcp_server2.inl @@ -1542,6 +1542,7 @@ namespace net_utils accept_function_pointer = &boosted_tcp_server::handle_accept_ipv6; } + bool accept_started = false; try { if (!e) @@ -1562,6 +1563,7 @@ namespace net_utils current_acceptor->async_accept((*current_new_connection)->socket(), boost::bind(accept_function_pointer, this, boost::asio::placeholders::error)); + accept_started = true; boost::asio::socket_base::keep_alive opt(true); conn->socket().set_option(opt); @@ -1587,6 +1589,8 @@ namespace net_utils catch (const std::exception &e) { MERROR("Exception in boosted_tcp_server::handle_accept: " << e.what()); + if (accept_started) + return; } // error path, if e or exception