changed the optimistic disconnect logic to be more efficient and configurable
This commit is contained in:
@@ -242,6 +242,9 @@ namespace libtorrent
|
||||
std::vector<int> const& allowed_fast();
|
||||
std::vector<int> const& suggested_pieces() const { return m_suggested_pieces; }
|
||||
|
||||
ptime connected_time() const { return m_connect; }
|
||||
ptime last_received() const { return m_last_receive; }
|
||||
|
||||
void timed_out();
|
||||
// this will cause this peer_connection to be disconnected.
|
||||
void disconnect(char const* message);
|
||||
|
@@ -248,7 +248,6 @@ namespace libtorrent
|
||||
const_iterator end_peer() const { return m_peers.end(); }
|
||||
|
||||
bool connect_one_peer();
|
||||
bool disconnect_one_peer();
|
||||
|
||||
bool has_peer(policy::peer const* p) const;
|
||||
|
||||
@@ -267,7 +266,6 @@ namespace libtorrent
|
||||
bool compare_peer(policy::peer const& lhs, policy::peer const& rhs
|
||||
, address const& external_ip) const;
|
||||
|
||||
iterator find_disconnect_candidate();
|
||||
iterator find_connect_candidate();
|
||||
|
||||
bool is_connect_candidate(peer const& p, bool finished);
|
||||
|
@@ -102,11 +102,7 @@ namespace libtorrent
|
||||
, min_reconnect_time(60)
|
||||
, peer_connect_timeout(7)
|
||||
, ignore_limits_on_local_network(true)
|
||||
#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
|
||||
, connection_speed(2)
|
||||
#else
|
||||
, connection_speed(20)
|
||||
#endif
|
||||
, send_redundant_have(false)
|
||||
, lazy_bitfields(true)
|
||||
, inactivity_timeout(600)
|
||||
@@ -134,6 +130,9 @@ namespace libtorrent
|
||||
, share_ratio_limit(2.f)
|
||||
, seed_time_ratio_limit(7.f)
|
||||
, seed_time_limit(24 * 60 * 60) // 24 hours
|
||||
, peer_turnover(1 / 50.f)
|
||||
, peer_turnover_cutoff(1.f)
|
||||
, close_redundant_connections(true)
|
||||
{}
|
||||
|
||||
// this is the user agent that will be sent to the tracker
|
||||
@@ -376,6 +375,23 @@ namespace libtorrent
|
||||
float share_ratio_limit;
|
||||
float seed_time_ratio_limit;
|
||||
int seed_time_limit;
|
||||
|
||||
// the percentage of peers to disconnect every
|
||||
// 90 seconds (if we're at the peer limit)
|
||||
// defaults to 1/50:th
|
||||
float peer_turnover;
|
||||
|
||||
// when we are connected to more than
|
||||
// limit * peer_turnover_enable peers
|
||||
// disconnect peer_turnover fraction
|
||||
// of the peers
|
||||
float peer_turnover_cutoff;
|
||||
|
||||
// if this is true (default) connections where both
|
||||
// ends have no utility in keeping the connection open
|
||||
// are closed. for instance if both ends have completed
|
||||
// their downloads
|
||||
bool close_redundant_connections;
|
||||
};
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
@@ -452,6 +452,7 @@ namespace libtorrent
|
||||
void announce_piece(int index);
|
||||
|
||||
void disconnect_all();
|
||||
int disconnect_peers(int num);
|
||||
|
||||
// this is called wheh the torrent has completed
|
||||
// the download. It will post an event, disconnect
|
||||
|
Reference in New Issue
Block a user