From 9f3d96eba6cc56d1ed6609cc7927c3561e789a3b Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Thu, 12 Jun 2025 17:46:42 -0400 Subject: [PATCH] Add check for exception in tcp accept handler --- contrib/epee/include/net/abstract_tcp_server2.inl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl index 7c671d0e49..bc1f801a47 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.inl +++ b/contrib/epee/include/net/abstract_tcp_server2.inl @@ -1540,6 +1540,7 @@ namespace net_utils accept_function_pointer = &boosted_tcp_server::handle_accept_ipv6; } + bool accept_started = false; try { if (!e) @@ -1560,6 +1561,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); @@ -1585,6 +1587,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