mirror of
https://github.com/monero-project/monero.git
synced 2025-05-06 10:15:00 -04:00
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.
This commit is contained in:
parent
8a7b3ff138
commit
55c7fb87a9
6 changed files with 77 additions and 19 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue