diff --git a/doc/rtorrent.1.xml b/doc/rtorrent.1.xml index 1f3669ae..80fec0f9 100644 --- a/doc/rtorrent.1.xml +++ b/doc/rtorrent.1.xml @@ -388,57 +388,6 @@ directory. - - max_peers = value - -Set the maximum number of peers to allow in each download. - - - - - min_peers = value - -Set the minimum number of peers to try to connect to in each download. - - - - - max_peers_seed = value - -Set the maximum number of peers to allow while seeding, or -1 (default) to use -max_peers. - - - - - min_peers_seed = value - -Set the minimum number of peers to try to connect to while seeding, or -1 (default) to use -min_peers. - - - - - max_uploads = value - -Set the maximum number of simultaneous uploads per download. - - - - - download_rate = KB - -Set the maximum global download rate. - - - - - upload_rate = KB - -Set the maximum global upload rate. - - - bind = a.b.c.d @@ -645,6 +594,69 @@ commands are available. + + THROTTLE SETTINGS + + + + + + + + upload_rate = KB + download_rate = KB + +Set the maximum global uploand and download rates. + + + + + min_peers = value + max_peers = value + +Set the minimum and maximum number of peers to allow in each download. + + + + + min_peers_seed = value + max_peers_seed = value + +Set the minimum nad maximum number of peers to allow while seeding, or +-1 (default) to use max_peers. + + + + + max_uploads = value + +Set the maximum number of simultaneous uploads per download. + + + + + max_uploads_div = value + max_downloads_div = value + +Change the divider used to calculate the max upload and download slots +to use when the throttle is changed. Disable by +setting 0. + + + + + max_uploads_global = value + max_downloads_global = value + +Max upload and download slots allowed. Disable by +setting 0. + + + + + + + TRACKER RELATED SETTINGS diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc index 7e118469..17f16d97 100644 --- a/src/option_handler_rules.cc +++ b/src/option_handler_rules.cc @@ -481,15 +481,19 @@ initialize_variables() { variables->insert("http_proxy", new utils::VariableStringSlot(rak::mem_fn(control->core()->get_poll_manager()->get_http_stack(), &core::CurlStack::http_proxy), rak::mem_fn(control->core()->get_poll_manager()->get_http_stack(), &core::CurlStack::set_http_proxy))); + variables->insert("max_chunks_queued", new utils::VariableValue(0)); variables->insert("min_peers", new utils::VariableValue(40)); variables->insert("max_peers", new utils::VariableValue(100)); variables->insert("min_peers_seed", new utils::VariableValue(-1)); variables->insert("max_peers_seed", new utils::VariableValue(-1)); + variables->insert("max_uploads", new utils::VariableValue(15)); variables->insert("max_uploads_div", new utils::VariableValue(1)); - variables->insert("max_chunks_queued", new utils::VariableValue(0)); - - variables->insert("max_downloads_hack", new utils::VariableValueSlot(rak::ptr_fn(&torrent::max_download_unchoked), rak::ptr_fn(&torrent::set_max_download_unchoked))); + variables->insert("max_uploads_global", new utils::VariableValueSlot(rak::mem_fn(control->ui(), &ui::Root::max_uploads_global), + rak::mem_fn(control->ui(), &ui::Root::set_max_uploads_global))); + variables->insert("max_downloads_div", new utils::VariableValue(0)); + variables->insert("max_downloads_global", new utils::VariableValueSlot(rak::mem_fn(control->ui(), &ui::Root::max_downloads_global), + rak::mem_fn(control->ui(), &ui::Root::set_max_downloads_global))); variables->insert("download_rate", new utils::VariableValueSlot(rak::ptr_fn(&torrent::down_throttle), rak::mem_fn(control->ui(), &ui::Root::set_down_throttle_i64), 0, (1 << 10))); diff --git a/src/ui/root.cc b/src/ui/root.cc index c1db80f5..8a356e07 100644 --- a/src/ui/root.cc +++ b/src/ui/root.cc @@ -64,7 +64,10 @@ Root::Root() : m_windowTitle(NULL), m_windowHttpQueue(NULL), m_windowInput(NULL), - m_windowStatusbar(NULL) { + m_windowStatusbar(NULL), + + m_maxUploadsGlobal(0), + m_maxDownloadsGlobal(0) { } void @@ -162,6 +165,27 @@ Root::set_down_throttle(unsigned int throttle) { m_windowStatusbar->mark_dirty(); torrent::set_down_throttle(throttle * 1024); + + int64_t div = control->variable()->get_value("max_downloads_div"); + + if (throttle == 0 || div <= 0) { + torrent::set_max_download_unchoked(m_maxDownloadsGlobal); + return; + } + + throttle /= control->variable()->get_value("max_downloads_div"); + + unsigned int maxUnchoked; + + if (throttle <= 10) + maxUnchoked = 1 + throttle / 1; + else + maxUnchoked = 10 + throttle / 5; + + if (m_maxDownloadsGlobal != 0) + torrent::set_max_download_unchoked(std::min(maxUnchoked, m_maxDownloadsGlobal)); + else + torrent::set_max_download_unchoked(maxUnchoked); } void @@ -171,17 +195,26 @@ Root::set_up_throttle(unsigned int throttle) { torrent::set_up_throttle(throttle * 1024); - if (throttle == 0) { - torrent::set_max_unchoked(0); + int64_t div = control->variable()->get_value("max_uploads_div"); + + if (throttle == 0 || div <= 0) { + torrent::set_max_unchoked(m_maxUploadsGlobal); return; } throttle /= control->variable()->get_value("max_uploads_div"); + unsigned int maxUnchoked; + if (throttle <= 10) - torrent::set_max_unchoked(1 + throttle / 1); + maxUnchoked = 1 + throttle / 1; else - torrent::set_max_unchoked(10 + throttle / 5); + maxUnchoked = 10 + throttle / 5; + + if (m_maxUploadsGlobal != 0) + torrent::set_max_unchoked(std::min(maxUnchoked, m_maxUploadsGlobal)); + else + torrent::set_max_unchoked(maxUnchoked); } void @@ -194,6 +227,26 @@ Root::adjust_up_throttle(int throttle) { set_up_throttle(std::max(torrent::up_throttle() / 1024 + throttle, 0)); } +void +Root::set_max_uploads_global(int64_t slots) { + if (slots < 0) + throw torrent::input_error("Out of range."); + + m_maxUploadsGlobal = slots; + + set_up_throttle(torrent::up_throttle() / 1024); +} + +void +Root::set_max_downloads_global(int64_t slots) { + if (slots < 0) + throw torrent::input_error("Out of range."); + + m_maxDownloadsGlobal = slots; + + set_down_throttle(torrent::down_throttle() / 1024); +} + void Root::enable_input(const std::string& title, input::TextInput* input) { if (m_windowInput->input() != NULL) diff --git a/src/ui/root.h b/src/ui/root.h index d3a2873a..37927205 100644 --- a/src/ui/root.h +++ b/src/ui/root.h @@ -84,6 +84,12 @@ public: void adjust_down_throttle(int throttle); void adjust_up_throttle(int throttle); + unsigned int max_uploads_global() { return m_maxUploadsGlobal; } + void set_max_uploads_global(int64_t slots); + + unsigned int max_downloads_global() { return m_maxDownloadsGlobal; } + void set_max_downloads_global(int64_t slots); + void enable_input(const std::string& title, input::TextInput* input); void disable_input(); @@ -101,6 +107,9 @@ private: WStatusbar* m_windowStatusbar; input::Bindings m_bindings; + + unsigned int m_maxUploadsGlobal; + unsigned int m_maxDownloadsGlobal; }; }