A downloading torrent closes its connections to peers that keep it waiting, so it can dial peers that send. libtorrent 0.16.27 dials peers from its list only while a torrent holds fewer than d.peers_min connections (DownloadMain::receive_connect_peers) and takes incoming connections up to d.peers_max (ConnectionList::insert, Handshake::validate_download). The connections between min and max can only come from peers that dial it. Nothing closes a connection that brings nothing: the only drop is 240 s without a byte read (receive_keepalive), and a peer's keepalive is a byte. So on a big swarm with an open port, seeds that dial in and keep the torrent choked (their upload slots taken by others) fill the slots above min, every peer that sent and went away (its client stopped, a VPN reconnected) is replaced by one more of them, and the torrent stops dialling for good. A peer that unchokes and answers no request does worse: it takes one of the torrent's download slots (d.downloads_max), and libtorrent rotates those slots only while some are free (choke_queue::retrieve_connections), so with all of them taken a seed that does send is never asked; this patch leaves the rotation as it is. Found 2026-11-02 from a user's report (a private torrent, 112 peers connected, all incoming seeds, one of them sending 8.9 KiB/s, nine hours after it had downloaded at 41 MiB/s from peers it had dialled); reproduced in tools/peer-slots-lab. The change: - Every connection keeps an idle clock (PeerConnectionBase::update_idle_time). It runs while the torrent is interested in the peer and no piece data move either way. Piece data in either direction, an unchoke from the peer (a seed that rotates its upload slots) or the torrent not being interested put it back to 0. It stops while the peer has unchoked the torrent and the torrent's own download slots keep it from asking, and while the peer wants the torrent's pieces (ratio on a private tracker): the wait is the torrent's, not the peer's. - On every 30-second tick, before the tick dials, a torrent that is downloading (active, not complete, not a magnet's metadata) and holds d.peers_min connections or more closes the connections whose clock reached 5 minutes, on every fourth tick (the two-minute pass), or 90 seconds while it is stalled (DownloadMain::drop_idle_peers). Stalled (StallWatch): two ticks in a row that each brought less than a tenth of its best tick of the last ten minutes, or less than 2 KiB/s. 90 seconds are three optimistic-unchoke rounds (30 s in the BitTorrent specification). Below min the torrent dials by itself and nothing is closed, so a small swarm is never thinned. A complete torrent (seeding) is never touched. The pass writes one torrent_events line when it closed something; each peer is a peer_list_events line. - A closed peer is refused, incoming and outgoing, for 30 minutes from the close (PeerInfo::flag_idle_dropped, PeerList::idle_refuse_seconds, checked in PeerList::connected), so it cannot take the slot straight back. libtorrent keeps a peer's entry 24 hours after its last connection, so the window holds. - Once the closes take the torrent under min, the tick's receive_connect_peers dials what is on the torrent's list of addresses to dial: the tracker's answers it has not dialled yet and, since libtorrent-working-peers-redial.patch, the peers whose working connections closed on their side. The peers this rule closes do not go on that list, and nothing here asks the tracker: libtorrent asks it again on the tracker's own schedule. - The numbers are settings (idle_peer_rules in torrent/peer/peer_list.h, one set for the whole client, read on every tick, so a change takes effect at the next one), each with its default as above: the rule on or off, the regular timeout (300 s) and pass interval (120 s), the refusal window (1800 s, 0 for none), the starved pass on or off, its timeout (90 s), its check interval (30 s; the intervals are whole 30-second ticks), and the two starvation tests (10 percent of the best check of the last ten minutes, 2048 bytes a second; 0 switches a test off). A setter refuses a value out of its range with input_error. DownloadMain::idle_tick_for() says which pass a tick runs. rtorrent's throttle.idle_peers.* commands (rtorrent-peer-rules-commands.patch) read and set them. With the rule off the idle clocks still run, so its first pass after it is switched on sees each peer's real idle time. Verified by 21 cppunit tests in tests/libtorrent-unused-peer-slots.tests.patch (the clock in each state, the refusal window, the stall watch), upstream's suites with every patch (tools/libtorrent-test.sh 9 of 9, tools/rtorrent-test.sh 3 of 3) and tools/peer-slots-lab against native builds (D335, docs/notes/2026-11-02-peer-slots.md): with dead seeds above min and the seeds it had dialled gone, the unpatched client downloaded nothing for 16 minutes and the patched one had data again 75 s after the seeds changed; in a working swarm both finished the same 1 GiB in about the same time and the patched one closed only a seed that unchokes once in 10 minutes. diff --git a/src/download/download_main.cc b/src/download/download_main.cc index 8fa8911..9bece6b 100644 --- a/src/download/download_main.cc +++ b/src/download/download_main.cc @@ -2,7 +2,9 @@ #include "download/download_main.h" +#include #include +#include #include #include "manager.h" @@ -23,6 +25,7 @@ #include "torrent/download/choke_queue.h" #include "torrent/download/download_manager.h" #include "torrent/download_info.h" +#include "torrent/net/socket_address.h" #include "torrent/peer/connection_list.h" #include "torrent/peer/peer.h" #include "torrent/peer/peer_info.h" @@ -319,6 +322,118 @@ DownloadMain::receive_connect_peers() { } } +bool +StallWatch::update(uint64_t total, uint32_t interval) { + if (interval == 0) + interval = idle_peer_rules::tick; + + if (!m_primed || total < m_last_total || interval != m_interval) { + *this = StallWatch{}; + m_primed = true; + m_interval = interval; + m_last_total = total; + return false; + } + + // The checks of the last ten minutes: 20 at 30 s, 10 at 60 s, one at 600 s. + uint32_t kept = std::clamp(window / interval, 1, history_size); + uint64_t got = total - m_last_total; + uint64_t best = 0; + + for (uint32_t i = 0; i < kept; i++) + best = std::max(best, m_history[i]); + + m_last_total = total; + m_history[m_pos] = got; + m_pos = (m_pos + 1) % kept; + + uint64_t floor = static_cast(idle_peer_rules::starved_floor()) * interval; + uint64_t ratio = idle_peer_rules::starved_ratio(); + + if ((floor != 0 && got < floor) || got * 100 < best * ratio) + m_starved++; + else + m_starved = 0; + + return stalled(); +} + +DownloadMain::idle_tick +DownloadMain::idle_tick_for(uint32_t ticks) { + // The starvation check runs every starved_interval(), the regular pass every pass_interval(), both in whole ticks. + if (!idle_peer_rules::enabled()) + return {}; + + return {idle_peer_rules::starved() && ticks % (idle_peer_rules::starved_interval() / idle_peer_rules::tick) == 0, + ticks % (idle_peer_rules::pass_interval() / idle_peer_rules::tick) == 0}; +} + +void +DownloadMain::drop_idle_peers(uint32_t ticks) { + if (!info()->is_active() || info()->is_meta_download() || file_list()->is_done()) { + m_stall_watch.reset(); + m_stalled = false; + return; + } + + auto [check, regular] = idle_tick_for(ticks); + + if (!idle_peer_rules::enabled() || !idle_peer_rules::starved()) { + m_stall_watch.reset(); + m_stalled = false; + } else if (check) { + m_stalled = m_stall_watch.update(info()->down_rate()->total(), idle_peer_rules::starved_interval()); + } + + bool stalled = check && m_stalled; + + // Every connection's clock moves on every tick, also while the rule is off, so a peer's idle time is right when the + // count reaches min later or the rule is switched on. + auto now = this_thread::cached_seconds(); + auto limit = std::chrono::seconds(stalled ? idle_peer_rules::starved_timeout() : idle_peer_rules::timeout()); + + if (!stalled && !regular) { + for (auto& peer : *connection_list()) + peer->m_ptr()->update_idle_time(now); + + return; + } + + uint32_t idle = 0; + + for (auto& peer : *connection_list()) + if (peer->m_ptr()->update_idle_time(now) >= limit) + idle++; + + if (idle == 0 || connection_list()->size() < connection_list()->min_size()) + return; + + auto before = connection_list()->size(); + uint32_t incoming = 0; + + for (auto itr = connection_list()->begin(); itr != connection_list()->end();) { + auto pcb = (*itr)->m_ptr(); + + if (pcb->idle_time() < limit) { + itr++; + continue; + } + + lt_log_print_info(LOG_PEER_LIST_EVENTS, info(), "peer_list : dropped idle peer : %s : incoming:%i", + sa_pretty_str(pcb->peer_info()->socket_address()).c_str(), static_cast(pcb->peer_info()->is_incoming())); + + incoming += pcb->peer_info()->is_incoming() ? 1 : 0; + itr = connection_list()->erase(itr, ConnectionList::disconnect_idle); + } + + auto after = connection_list()->size(); + + lt_log_print_info(LOG_TORRENT_EVENTS, info(), "download : dropped %zu idle peers (%" PRIu32 " incoming) : idle %llds%s : connections %zu -> %zu : min:%zu available:%zu", + static_cast(before - after), incoming, static_cast(limit.count()), stalled ? ", stalled" : "", + static_cast(before), static_cast(after), + static_cast(connection_list()->min_size()), static_cast(peer_list()->available_list()->size())); +} + void DownloadMain::receive_tracker_success() { assert(std::this_thread::get_id() == main_thread::thread_id()); diff --git a/src/download/download_main.h b/src/download/download_main.h index 8ed4fb6..7da3f70 100644 --- a/src/download/download_main.h +++ b/src/download/download_main.h @@ -1,6 +1,7 @@ #ifndef LIBTORRENT_DOWNLOAD_MAIN_H #define LIBTORRENT_DOWNLOAD_MAIN_H +#include #include #include @@ -28,6 +29,31 @@ class DownloadInfo; class ThrottleList; class InitialSeeding; +// A download's own rate, one check at a time (every idle_peer_rules::starved_interval(), 30 s by default). A check is +// starved when it brought less than idle_peer_rules::starved_ratio() percent of the best check of the last ten +// minutes (10), or less than idle_peer_rules::starved_floor() bytes a second (2 KiB/s); the download is stalled after +// two starved checks in a row. A change of the interval starts the history again. +class StallWatch { +public: + static constexpr uint32_t history_size = 20; + static constexpr uint32_t window = 600; + static constexpr uint32_t stalled_after = 2; + + // total: the download's whole received count, read once a check; interval: the seconds since the last check. + // Returns whether the download is stalled. + bool update(uint64_t total, uint32_t interval = idle_peer_rules::default_starved_interval); + bool stalled() const { return m_starved >= stalled_after; } + void reset() { *this = StallWatch{}; } + +private: + std::array m_history{}; + uint32_t m_pos{}; + uint32_t m_interval{}; + uint64_t m_last_total{}; + bool m_primed{}; + uint32_t m_starved{}; +}; + class DownloadMain { public: using have_queue_type = std::deque>; @@ -101,6 +127,25 @@ public: void add_peer(const sockaddr* sa); void receive_connect_peers(); + + // A download that still downloads and holds d.peers_min connections or more no longer dials (see + // receive_connect_peers). Its connections to peers that kept it waiting are closed so the slots go to peers it can + // dial: after idle_peer_rules::timeout() on the regular pass (every pass_interval()), after starved_timeout() on a + // starvation check that finds the download stalled (StallWatch, every starved_interval()). Nothing is closed while + // the rule is off (idle_peer_rules::enabled()); the starved pass only while starved() is on. See + // PeerConnectionBase::update_idle_time and idle_peer_rules::refuse_time(). + // + // Called every 30 seconds with the manager's tick count. + void drop_idle_peers(uint32_t ticks); + + // Which of the rule's passes a tick runs (idle_peer_rules): the starvation check, the regular pass, either, both or + // none (the rule off). Pure: the tests drive it. + struct idle_tick { + bool check{}; + bool regular{}; + }; + static idle_tick idle_tick_for(uint32_t ticks); + void receive_chunk_done(unsigned int index); void receive_corrupt_chunk(PeerInfo* peerInfo); @@ -117,7 +162,12 @@ public: auto& delay_disconnect_peers() { return m_delay_disconnect_peers; } + const StallWatch& stall_watch() const { return m_stall_watch; } + private: + StallWatch m_stall_watch; + bool m_stalled{}; + DownloadInfo* m_info; tracker::TrackerControllerWrapper m_tracker_controller; diff --git a/src/download/download_wrapper.cc b/src/download/download_wrapper.cc index 8c4f14d..0ca20a8 100644 --- a/src/download/download_wrapper.cc +++ b/src/download/download_wrapper.cc @@ -281,6 +281,8 @@ DownloadWrapper::receive_tick(uint32_t ticks) { itr++; } + m_main->drop_idle_peers(ticks); + auto have_queue = m_main->have_queue(); have_queue->erase(std::find_if(have_queue->rbegin(), diff --git a/src/protocol/peer_connection_base.cc b/src/protocol/peer_connection_base.cc index 094fe2b..c14e1cd 100644 --- a/src/protocol/peer_connection_base.cc +++ b/src/protocol/peer_connection_base.cc @@ -123,6 +123,7 @@ PeerConnectionBase::initialize(DownloadMain* download, PeerInfo* peerInfo, int f this_thread::poll()->insert_write(this); m_time_last_read = this_thread::cached_time(); + m_idle_seen = this_thread::cached_seconds(); m_download->chunk_statistics()->received_connect(&m_peer_chunks); @@ -190,6 +191,31 @@ PeerConnectionBase::set_peer_exchange(bool state) { } } +std::chrono::seconds +PeerConnectionBase::update_idle_time(std::chrono::seconds now) { + auto elapsed = now - m_idle_seen; + auto down = m_peer_chunks.download_throttle()->rate()->total(); + auto up = m_peer_chunks.upload_throttle()->rate()->total(); + + m_idle_seen = now; + + if (!m_down_interested || down != m_idle_down || up != m_idle_up || m_idle_unchoked) { + m_idle_down = down; + m_idle_up = up; + m_idle_unchoked = false; + m_idle_time = std::chrono::seconds{}; + return m_idle_time; + } + + // The wait is ours: it unchoked us while our download slots are taken, or it wants our pieces while our upload + // slots are. + if ((m_down_unchoked && !m_down_choke.unchoked()) || m_up_choke.queued()) + return m_idle_time; + + m_idle_time += elapsed; + return m_idle_time; +} + void PeerConnectionBase::set_upload_snubbed(bool v) { if (v) diff --git a/src/protocol/peer_connection_base.h b/src/protocol/peer_connection_base.h index 4d78724..21936dd 100644 --- a/src/protocol/peer_connection_base.h +++ b/src/protocol/peer_connection_base.h @@ -107,6 +107,13 @@ public: bool should_connection_unchoke(choke_queue* cq) const; + // How long this connection has been of no use to the download: we want its data, it did not unchoke us, and no + // piece data went either way. A connection that unchoked us while our own download slots keep us from asking it, + // or that wants our pieces, is not charged (the wait is ours). Called every two minutes by + // DownloadMain::drop_idle_peers. + std::chrono::seconds update_idle_time(std::chrono::seconds now); + std::chrono::seconds idle_time() const { return m_idle_time; } + protected: static constexpr uint32_t extension_must_encrypt = ~uint32_t(); @@ -183,6 +190,12 @@ protected: std::chrono::microseconds m_time_last_read{}; + std::chrono::seconds m_idle_seen{}; + std::chrono::seconds m_idle_time{}; + uint64_t m_idle_down{}; + uint64_t m_idle_up{}; + bool m_idle_unchoked{}; // It unchoked us since the last look. + DataBuffer m_extension_message; uint32_t m_extension_offset; diff --git a/src/protocol/peer_connection_leech.cc b/src/protocol/peer_connection_leech.cc index 417e15d..bf0ba56 100644 --- a/src/protocol/peer_connection_leech.cc +++ b/src/protocol/peer_connection_leech.cc @@ -205,6 +205,7 @@ PeerConnection::read_message() { return true; m_down_unchoked = true; + m_idle_unchoked = true; // Some peers unchoke us even though we're not interested, so we // need to ensure it doesn't get added to the queue. diff --git a/src/torrent/peer/connection_list.cc b/src/torrent/peer/connection_list.cc index 2a9943f..5308bea 100644 --- a/src/torrent/peer/connection_list.cc +++ b/src/torrent/peer/connection_list.cc @@ -110,7 +110,8 @@ ConnectionList::erase(iterator pos, int flags) { peerConnection->cleanup(); peerConnection->mutable_peer_info()->set_connection(NULL); - m_download->peer_list()->disconnected(peerConnection->mutable_peer_info(), PeerList::disconnect_set_time); + m_download->peer_list()->disconnected(peerConnection->mutable_peer_info(), + PeerList::disconnect_set_time | ((flags & disconnect_idle) ? PeerList::disconnect_idle : 0)); // Delete after the signal to ensure the address of 'v' doesn't get // allocated for a different PCB in the signal. diff --git a/src/torrent/peer/connection_list.h b/src/torrent/peer/connection_list.h index de53c68..9d464f4 100644 --- a/src/torrent/peer/connection_list.h +++ b/src/torrent/peer/connection_list.h @@ -58,6 +58,7 @@ public: static constexpr int disconnect_quick = (1 << 1); static constexpr int disconnect_unwanted = (1 << 2); static constexpr int disconnect_delayed = (1 << 3); + static constexpr int disconnect_idle = (1 << 4); ConnectionList(DownloadMain* download); ~ConnectionList() = default; diff --git a/src/torrent/peer/peer_info.h b/src/torrent/peer/peer_info.h index 554f32f..b223b26 100644 --- a/src/torrent/peer/peer_info.h +++ b/src/torrent/peer/peer_info.h @@ -24,6 +24,7 @@ public: static constexpr int flag_restart = (1 << 4); static constexpr int flag_unwanted = (1 << 5); static constexpr int flag_preferred = (1 << 6); + static constexpr int flag_idle_dropped = (1 << 7); // Dropped as idle; refused until PeerList::idle_refuse_seconds pass. static constexpr int mask_ip_table = flag_unwanted | flag_preferred; @@ -37,6 +38,7 @@ public: bool is_restart() const { return m_flags & flag_restart; } bool is_unwanted() const { return m_flags & flag_unwanted; } bool is_preferred() const { return m_flags & flag_preferred; } + bool is_idle_dropped() const { return m_flags & flag_idle_dropped; } int flags() const { return m_flags; } diff --git a/src/torrent/peer/peer_list.cc b/src/torrent/peer/peer_list.cc index 5c8d7ca..0220647 100644 --- a/src/torrent/peer/peer_list.cc +++ b/src/torrent/peer/peer_list.cc @@ -28,8 +28,36 @@ is_unroutable_peer(const sockaddr* sa) { return sa_is_any(sa) || sa_is_broadcast(sa) || sa_is_loopback(sa) || sa_is_link_local(sa); } +void +check_seconds(const char* what, uint32_t v, uint32_t lo, uint32_t hi, bool whole_ticks) { + if (v < lo || v > hi || (whole_ticks && v % idle_peer_rules::tick != 0)) + throw input_error(std::string(what) + ": " + std::to_string(v) + " is out of range (" + std::to_string(lo) + " to " + + std::to_string(hi) + (whole_ticks ? ", a multiple of 30)" : ")")); +} + } // namespace +void idle_peer_rules::set_timeout(uint32_t v) { check_seconds("idle peer timeout", v, 30, 86400, false); s_timeout = v; } +void idle_peer_rules::set_pass_interval(uint32_t v) { check_seconds("idle peer pass interval", v, 30, 3600, true); s_pass_interval = v; } +void idle_peer_rules::set_refuse_time(uint32_t v) { check_seconds("idle peer refuse time", v, 0, 86400, false); s_refuse_time = v; } +void idle_peer_rules::set_starved_timeout(uint32_t v) { check_seconds("starved idle peer timeout", v, 30, 3600, false); s_starved_timeout = v; } +void idle_peer_rules::set_starved_interval(uint32_t v) { check_seconds("starved check interval", v, 30, 600, true); s_starved_interval = v; } +void idle_peer_rules::set_starved_ratio(uint32_t v) { check_seconds("starved ratio", v, 0, 100, false); s_starved_ratio = v; } +void idle_peer_rules::set_starved_floor(uint32_t v) { check_seconds("starved floor", v, 0, 1u << 30, false); s_starved_floor = v; } + +void +idle_peer_rules::reset() { + s_enabled = default_enabled; + s_timeout = default_timeout; + s_pass_interval = default_pass_interval; + s_refuse_time = default_refuse_time; + s_starved = default_starved; + s_starved_timeout = default_starved_timeout; + s_starved_interval = default_starved_interval; + s_starved_ratio = default_starved_ratio; + s_starved_floor = default_starved_floor; +} + ipv4_table PeerList::m_ipv4_table; PeerList::PeerList() @@ -263,6 +291,18 @@ PeerList::connected(const sockaddr* sa, int flags) { } else if (!range.first->second->is_connected()) { // Use an old entry. peer_info = range.first->second.get(); + + if (peer_info->is_idle_dropped()) { + auto since = static_cast(this_thread::cached_seconds().count()) - peer_info->last_connection(); + + if (since < idle_peer_rules::refuse_time()) { + LT_LOG_EVENTS("connecting peer rejected: dropped as idle %" PRIu32 " s ago : %s", since, sa_pretty_str(sa).c_str()); + return nullptr; + } + + peer_info->unset_flags(PeerInfo::flag_idle_dropped); + } + peer_info->set_port(port); } else { @@ -359,6 +399,11 @@ PeerList::disconnected(iterator itr, int flags) { if (flags & disconnect_set_time) itr->second->set_last_connection(this_thread::cached_seconds().count()); + if (flags & disconnect_idle) { + itr->second->set_last_connection(this_thread::cached_seconds().count()); + itr->second->set_flags(PeerInfo::flag_idle_dropped); + } + if (flags & disconnect_available && itr->second->listen_port() != 0) m_available_list->insert_unique(itr->second->socket_address()); diff --git a/src/torrent/peer/peer_list.h b/src/torrent/peer/peer_list.h index c4c775f..dfa72f7 100644 --- a/src/torrent/peer/peer_list.h +++ b/src/torrent/peer/peer_list.h @@ -15,6 +15,59 @@ class raw_string; using ipv4_table = extents; +// The idle-peer rule's numbers (DownloadMain::drop_idle_peers, StallWatch, PeerList::connected), one set for the +// whole client, read on every tick so a change takes effect at the next one. The defaults are the rule's own; a +// setter throws input_error on a value out of its range. Times are in seconds; the intervals are whole download +// ticks (30 s each). +class LIBTORRENT_EXPORT idle_peer_rules { +public: + static constexpr uint32_t tick = 30; + + static constexpr bool default_enabled = true; + static constexpr uint32_t default_timeout = 300; // closed after this long idle, on the regular pass + static constexpr uint32_t default_pass_interval = 120; // the regular pass runs this often + static constexpr uint32_t default_refuse_time = 1800; // a closed peer is refused this long (0: not at all) + static constexpr bool default_starved = true; + static constexpr uint32_t default_starved_timeout = 90; // closed after this long idle while the download starves + static constexpr uint32_t default_starved_interval = 30; // the starvation check and its pass run this often + static constexpr uint32_t default_starved_ratio = 10; // starved: under this percent of the best of 10 minutes (0: off) + static constexpr uint32_t default_starved_floor = 2048; // or under this many bytes a second (0: off) + + static bool enabled() { return s_enabled; } + static uint32_t timeout() { return s_timeout; } + static uint32_t pass_interval() { return s_pass_interval; } + static uint32_t refuse_time() { return s_refuse_time; } + static bool starved() { return s_starved; } + static uint32_t starved_timeout() { return s_starved_timeout; } + static uint32_t starved_interval() { return s_starved_interval; } + static uint32_t starved_ratio() { return s_starved_ratio; } + static uint32_t starved_floor() { return s_starved_floor; } + + static void set_enabled(bool v) { s_enabled = v; } + static void set_timeout(uint32_t v); // 30 to 86400 + static void set_pass_interval(uint32_t v); // a multiple of 30, 30 to 3600 + static void set_refuse_time(uint32_t v); // 0 to 86400 + static void set_starved(bool v) { s_starved = v; } + static void set_starved_timeout(uint32_t v); // 30 to 3600 + static void set_starved_interval(uint32_t v); // a multiple of 30, 30 to 600 + static void set_starved_ratio(uint32_t v); // 0 to 100 + static void set_starved_floor(uint32_t v); // 0 to 1073741824 + + // Every number back to its default (the tests). + static void reset(); + +private: + static inline bool s_enabled{default_enabled}; + static inline uint32_t s_timeout{default_timeout}; + static inline uint32_t s_pass_interval{default_pass_interval}; + static inline uint32_t s_refuse_time{default_refuse_time}; + static inline bool s_starved{default_starved}; + static inline uint32_t s_starved_timeout{default_starved_timeout}; + static inline uint32_t s_starved_interval{default_starved_interval}; + static inline uint32_t s_starved_ratio{default_starved_ratio}; + static inline uint32_t s_starved_floor{default_starved_floor}; +}; + class LIBTORRENT_EXPORT PeerList : private std::multimap> { public: friend class DownloadWrapper; @@ -48,6 +101,11 @@ public: static constexpr int disconnect_quick = (1 << 1); static constexpr int disconnect_unwanted = (1 << 2); static constexpr int disconnect_set_time = (1 << 3); + static constexpr int disconnect_idle = (1 << 4); + + // A peer a download dropped as idle (DownloadMain::drop_idle_peers) is refused, incoming and outgoing, for + // idle_peer_rules::refuse_time() after the drop (30 minutes by default), so it cannot take the freed slot straight + // back. static constexpr int cull_old = (1 << 0); static constexpr int cull_keep_interesting = (1 << 1);