From 2b4cab30fc47539a87b4644c7cf4c657da391c0c Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 20 Mar 2016 12:05:55 +0000 Subject: epee: fix potential hang on exit Also close sockets on failure, just in case --- contrib/epee/include/net/abstract_tcp_server2.inl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl index 698e1947a..1c854dfb7 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.inl +++ b/contrib/epee/include/net/abstract_tcp_server2.inl @@ -1005,6 +1005,12 @@ POP_WARNINGS while(local_shared_context->ec == boost::asio::error::would_block) { bool r = local_shared_context->cond.timed_wait(lock, boost::get_system_time() + boost::posix_time::milliseconds(conn_timeout)); + if (m_stop_signal_sent) + { + if (sock_.is_open()) + sock_.close(); + return false; + } if(local_shared_context->ec == boost::asio::error::would_block && !r) { //timeout @@ -1018,6 +1024,8 @@ POP_WARNINGS if (ec || !sock_.is_open()) { _dbg3("Some problems at connect, message: " << ec.message()); + if (sock_.is_open()) + sock_.close(); return false; } -- cgit v1.2.3