aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/net/abstract_tcp_server2.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-06-07 12:43:10 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-06-10 19:39:38 +0100
commit55c7fb87a99cbd89fe2d98de7bde9854ee12b161 (patch)
tree5640c7b184b57cb3ede100a9f3983337acbc1c2c /contrib/epee/include/net/abstract_tcp_server2.h
parentMerge pull request #3866 (diff)
downloadmonero-55c7fb87a99cbd89fe2d98de7bde9854ee12b161.tar.xz
epee: adaptive connection timeout system
a connection's timeout is halved for every extra connection from the same host. Also keep track of when we don't need to use a connection anymore, so we can close it and free the resource for another connection. Also use the longer timeout for non routable local addresses.
Diffstat (limited to 'contrib/epee/include/net/abstract_tcp_server2.h')
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/epee/include/net/abstract_tcp_server2.h b/contrib/epee/include/net/abstract_tcp_server2.h
index 2f7325be5..7ca6ac872 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.h
+++ b/contrib/epee/include/net/abstract_tcp_server2.h
@@ -119,6 +119,7 @@ namespace net_utils
//----------------- i_service_endpoint ---------------------
virtual bool do_send(const void* ptr, size_t cb); ///< (see do_send from i_service_endpoint)
virtual bool do_send_chunk(const void* ptr, size_t cb); ///< will send (or queue) a part of data
+ virtual bool send_done();
virtual bool close();
virtual bool call_run_once_service_io();
virtual bool request_callback();
@@ -137,8 +138,11 @@ namespace net_utils
/// reset connection timeout timer and callback
void reset_timer(boost::posix_time::milliseconds ms, bool add);
- boost::posix_time::milliseconds get_default_time() const;
- boost::posix_time::milliseconds get_timeout_from_bytes_read(size_t bytes) const;
+ boost::posix_time::milliseconds get_default_timeout();
+ boost::posix_time::milliseconds get_timeout_from_bytes_read(size_t bytes);
+
+ /// host connection count tracking
+ unsigned int host_count(const std::string &host, int delta = 0);
/// Buffer for incoming data.
boost::array<char, 8192> buffer_;
@@ -165,6 +169,8 @@ namespace net_utils
boost::asio::deadline_timer m_timer;
bool m_local;
+ bool m_ready_to_close;
+ std::string m_host;
public:
void setRpcStation();