diff --git a/Makefile.am b/Makefile.am index 4d2ccdeb..c432ae60 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,7 @@ SUBDIRS = src EXTRA_DIST= \ autogen.sh \ doc/rtorrent.1.txt \ + doc/rtorrent.rc \ rak/algorithm.h \ rak/functional.h \ scripts/checks.m4 \ diff --git a/doc/rtorrent.rc b/doc/rtorrent.rc index 94a5b51d..72a01faa 100644 --- a/doc/rtorrent.rc +++ b/doc/rtorrent.rc @@ -2,30 +2,36 @@ # ~/.rtorrent.rc and enable/modify the options as needed. # Minumum amount of peers to connect per torrent, if available. -# min_peers = 40 +#min_peers = 40 # Minumum amount of peers to connect per torrent. -# max_peers = 100 +#max_peers = 100 # Maximum number of simultanious uploads per torrent. -# max_uploads = 15 +#max_uploads = 15 # Global download rate in KiB. "0" for unlimited. -# download_rate = 0 +#download_rate = 0 # Global upload rate in KiB. "0" for unlimited. -# upload_rate = 0 +#upload_rate = 0 # Default directory to save downloaded files. Note it doesn't support # space yet. -# directory = ./ +#directory = ./ # The ip address reported to the tracker. -# ip = 127.0.0.1 +#ip = 127.0.0.1 # The ip address the listening socket and outgoing connections is # bound to. -# bind = 127.0.0.1 +#bind = 127.0.0.1 # Port range to use for listening. -# port = 6890-6999 +#port = 6890-6999 + +# Hash read-ahead controls how many MB to request the kernel to read +# ahead. If the value is too low the disk may not be fully utilized, +# while if too high the kernel might not be able to keep the read +# pages in memory thus end up trashing. +#hash_read_ahead = 10 diff --git a/src/core/poll.cc b/src/core/poll.cc index d4695c2f..7dbb31ee 100644 --- a/src/core/poll.cc +++ b/src/core/poll.cc @@ -55,7 +55,7 @@ Poll::poll(utils::Timer timeout) { m_maxFd = std::max(m_maxFd, n); } - timeval t = std::min(timeout, utils::Timer(torrent::get(torrent::TIME_SELECT))).tval(); + timeval t = std::min(timeout, utils::Timer(torrent::get_next_timeout())).tval(); errno = 0; m_maxFd = select(m_maxFd + 1, m_readSet, m_writeSet, m_exceptSet, &t); diff --git a/src/display/window_statusbar.cc b/src/display/window_statusbar.cc index 90c55260..ab5f2fb5 100644 --- a/src/display/window_statusbar.cc +++ b/src/display/window_statusbar.cc @@ -46,22 +46,22 @@ WindowStatusbar::redraw() { int pos = 0; char buf[128]; - if (torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) == 0) + if (torrent::get_write_throttle() == 0) pos = snprintf(buf, 128, "off/"); else - pos = snprintf(buf, 128, "%3i/", (int)torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) / 1024); + pos = snprintf(buf, 128, "%3i/", torrent::get_write_throttle() / 1024); - if (torrent::get(torrent::THROTTLE_READ_CONST_RATE) == 0) + if (torrent::get_read_throttle() == 0) pos = snprintf(buf + pos, 128 - pos, "off"); else - pos = snprintf(buf + pos, 128 - pos, "%-3i", (int)torrent::get(torrent::THROTTLE_READ_CONST_RATE) / 1024); + pos = snprintf(buf + pos, 128 - pos, "%-3i", torrent::get_read_throttle() / 1024); m_canvas->print(0, 0, "Throttle U/D: %s Listen: %s:%i%s Handshakes: %i", buf, !torrent::get_ip().empty() ? torrent::get_ip().c_str() : "", - (int)torrent::get(torrent::LISTEN_PORT), + (int)torrent::get_listen_port(), !torrent::get_bind().empty() ? (" Bind: " + torrent::get_bind()).c_str() : "", - (int)torrent::get(torrent::HANDSHAKES_TOTAL)); + torrent::get_total_handshakes()); } } diff --git a/src/main.cc b/src/main.cc index 59b7ac16..97159e19 100644 --- a/src/main.cc +++ b/src/main.cc @@ -118,12 +118,13 @@ initialize_option_handler(ui::Control* c, OptionHandler* optionHandler) { optionHandler->insert("max_peers", new OptionHandlerDownloadInt(dsm, &apply_download_max_peers, &validate_download_peers)); optionHandler->insert("max_uploads", new OptionHandlerDownloadInt(dsm, &apply_download_max_uploads, &validate_download_peers)); - optionHandler->insert("download_rate", new OptionHandlerInt(c, &apply_global_download_rate, &validate_rate)); - optionHandler->insert("upload_rate", new OptionHandlerInt(c, &apply_global_upload_rate, &validate_rate)); + optionHandler->insert("download_rate", new OptionHandlerInt(c, &apply_global_download_rate, &validate_rate)); + optionHandler->insert("upload_rate", new OptionHandlerInt(c, &apply_global_upload_rate, &validate_rate)); + optionHandler->insert("hash_read_ahead", new OptionHandlerInt(c, &apply_hash_read_ahead, &validate_read_ahead)); optionHandler->insert("directory", new OptionHandlerDownloadString(dsm, &apply_download_directory, &validate_directory)); - optionHandler->insert("ip", new OptionHandlerString(c, &apply_ip, &validate_ip)); + optionHandler->insert("ip", new OptionHandlerString(c, &apply_ip, &validate_ip)); optionHandler->insert("bind", new OptionHandlerString(c, &apply_bind, &validate_ip)); optionHandler->insert("port", new OptionHandlerString(c, &apply_port_range, &validate_port_range)); } @@ -132,10 +133,10 @@ void load_option_file(const std::string& filename, OptionHandler* optionHandler, bool require = false) { std::fstream f(filename.c_str(), std::ios::in); - if (!f.is_open()) + if (!f.is_open()) { + std::cout << "Could not open option file \"" << filename << "\"" << std::endl; return; - - std::cout << "Loaded option file \"" << filename << "\"" << std::endl; + } OptionFile optionFile; @@ -208,7 +209,7 @@ main(int argc, char** argv) { uiControl.get_display().adjust_layout(); - while (!is_shutting_down || !torrent::get(torrent::SHUTDOWN_DONE)) { + while (!is_shutting_down || !torrent::is_inactive()) { if (uiRoot.get_shutdown_received()) { do_shutdown(&uiControl); diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc index b6f1b1b9..4b8626c9 100644 --- a/src/option_handler_rules.cc +++ b/src/option_handler_rules.cc @@ -55,7 +55,12 @@ validate_download_peers(int arg) { bool validate_rate(int arg) { - return arg >= 0 && arg < (1 << 24); + return arg >= 0 && arg < (1 << 20); +} + +bool +validate_read_ahead(int arg) { + return arg >= 1 && arg < 64; } void @@ -82,12 +87,17 @@ apply_download_directory(core::Download* d, const std::string& arg) { void apply_global_download_rate(ui::Control* m, int arg) { - torrent::set(torrent::THROTTLE_READ_CONST_RATE, arg * 1024); + torrent::set_read_throttle(arg * 1024); } void apply_global_upload_rate(ui::Control* m, int arg) { - torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, arg * 1024); + torrent::set_write_throttle(arg * 1024); +} + +void +apply_hash_read_ahead(ui::Control* m, int arg) { + torrent::set_hash_read_ahead(arg << 20); } void diff --git a/src/option_handler_rules.h b/src/option_handler_rules.h index 56b07e96..7f4fca6b 100644 --- a/src/option_handler_rules.h +++ b/src/option_handler_rules.h @@ -40,6 +40,7 @@ bool validate_port_range(const std::string& arg); bool validate_download_peers(int arg); bool validate_rate(int arg); +bool validate_read_ahead(int arg); void apply_download_min_peers(core::Download* d, int arg); void apply_download_max_peers(core::Download* d, int arg); @@ -50,6 +51,8 @@ void apply_download_directory(core::Download* d, const std::string& arg); void apply_global_download_rate(ui::Control* m, int arg); void apply_global_upload_rate(ui::Control* m, int arg); +void apply_hash_read_ahead(ui::Control* m, int arg); + void apply_ip(ui::Control* m, const std::string& arg); void apply_bind(ui::Control* m, const std::string& arg); void apply_port_range(ui::Control* m, const std::string& arg); diff --git a/src/ui/download.cc b/src/ui/download.cc index 2281a747..2464bb26 100644 --- a/src/ui/download.cc +++ b/src/ui/download.cc @@ -184,14 +184,14 @@ void Download::receive_read_throttle(int t) { m_windowMainStatus->mark_dirty(); - torrent::set(torrent::THROTTLE_READ_CONST_RATE, torrent::get(torrent::THROTTLE_READ_CONST_RATE) + t * 1024); + torrent::set_read_throttle(torrent::get_read_throttle() + t * 1024); } void Download::receive_write_throttle(int t) { m_windowMainStatus->mark_dirty(); - torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024); + torrent::set_write_throttle(torrent::get_write_throttle() + t * 1024); } void diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index 8c36eaeb..a8f3ff05 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -53,7 +53,7 @@ DownloadList::DownloadList(Control* c) : m_window(c->get_display().end()), - m_windowTitle(new WTitle("rtorrent " VERSION " - " + torrent::get(torrent::LIBRARY_NAME))), + m_windowTitle(new WTitle("rTorrent " VERSION " - libTorrent " + torrent::get_version())), m_windowStatus(new WStatus(&c->get_core())), m_windowHttpQueue(new WHttp(&c->get_core().get_http_queue())), @@ -172,14 +172,14 @@ void DownloadList::receive_read_throttle(int t) { m_windowStatus->mark_dirty(); - torrent::set(torrent::THROTTLE_READ_CONST_RATE, torrent::get(torrent::THROTTLE_READ_CONST_RATE) + t * 1024); + torrent::set_read_throttle(torrent::get_read_throttle() + t * 1024); } void DownloadList::receive_write_throttle(int t) { m_windowStatus->mark_dirty(); - torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024); + torrent::set_write_throttle(torrent::get_write_throttle() + t * 1024); } void