aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/net/abstract_tcp_server2.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-23 11:19:16 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-23 11:19:16 +0000
commit22581a04415c571461368c434ece72e5756d4fbd (patch)
tree297d41978d509d57f9ce25cc3a35b33167b7fbe6 /contrib/epee/include/net/abstract_tcp_server2.h
parentMerge pull request #554 (diff)
downloadmonero-22581a04415c571461368c434ece72e5756d4fbd.tar.xz
epee: regularly cleanup connections we kept a reference to
Since connections from the ::connect method are now kept in a deque to be able to cancel them on exit, this leaks both memory and a file descriptor. Here, we clean those up after 30 seconds, to avoid this. 30 seconds is higher then the 5 second timeout used in the async code, so this should be safe. However, this is an assumption which would break if that async code was to start relying on longer timeouts.
Diffstat (limited to 'contrib/epee/include/net/abstract_tcp_server2.h')
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/contrib/epee/include/net/abstract_tcp_server2.h b/contrib/epee/include/net/abstract_tcp_server2.h
index 77396ade4..f3dd7291c 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.h
+++ b/contrib/epee/include/net/abstract_tcp_server2.h
@@ -279,6 +279,8 @@ namespace net_utils
bool is_thread_worker();
+ bool cleanup_connections();
+
/// The io_service used to perform asynchronous operations.
std::unique_ptr<boost::asio::io_service> m_io_service_local_instance;
boost::asio::io_service& io_service_;
@@ -306,7 +308,7 @@ namespace net_utils
connection_ptr new_connection_;
std::mutex connections_mutex;
- std::deque<connection_ptr> connections_;
+ std::deque<std::pair<boost::system_time, connection_ptr>> connections_;
}; // class <>boosted_tcp_server