From fdc56e8f0900ab8b7acf0cfd0310632442e50c13 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Fri, 10 Jun 2005 21:37:06 +0000 Subject: [PATCH] Added resource for max open files. Fixed bug that could cause infinit looping on SIGBUS. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@460 e378c898-3ddf-0310-93e7-cc216c733640 --- TODO | 10 +--------- doc/rtorrent.rc | 3 +++ src/core/curl_get.h | 2 ++ src/core/curl_stack.h | 2 ++ src/main.cc | 4 ++++ src/option_handler_rules.cc | 10 ++++++++++ src/option_handler_rules.h | 2 ++ 7 files changed, 24 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index eeea15fa..ad0b38f0 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ Polling during last phase of shutdown should be very quick, don't use normal timeout. -Make clear distinction of upload/download throttle. - Consider basing WindowPeer* on a common base class. Some kind of indication that a tracker request was tried, but won't be @@ -21,12 +19,6 @@ Make accumulate return the value, no refs please... > slow or broken or for various reasons you don't want to download it. -Show the bound listening ip. - -Bug: Add the same torrent while it is hash checking. - -Bug: Using ^s on a bad torrent does not catch the exception. - Show torrent creation date? Recheck hash key. @@ -35,4 +27,4 @@ Seperate download management from core::management. Allow switching/cycling of tracker. -Remember to add virtual dtor to OptionHandlerBase \ No newline at end of file +Remember to add virtual dtor to OptionHandlerBase diff --git a/doc/rtorrent.rc b/doc/rtorrent.rc index 72a01faa..2fc5182d 100644 --- a/doc/rtorrent.rc +++ b/doc/rtorrent.rc @@ -35,3 +35,6 @@ # 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 + +# Max number of files to keep open simultaniously. +#max_open_files = 100 diff --git a/src/core/curl_get.h b/src/core/curl_get.h index 66174bb0..04ef4fdf 100644 --- a/src/core/curl_get.h +++ b/src/core/curl_get.h @@ -33,6 +33,8 @@ struct CURLMsg; namespace core { +class CurlStack; + class CurlGet : public torrent::Http { public: friend class CurlStack; diff --git a/src/core/curl_stack.h b/src/core/curl_stack.h index b6b40775..11537599 100644 --- a/src/core/curl_stack.h +++ b/src/core/curl_stack.h @@ -27,6 +27,8 @@ namespace core { +class CurlGet; + class CurlStack { public: friend class CurlGet; diff --git a/src/main.cc b/src/main.cc index 97159e19..eed8651a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -121,6 +121,7 @@ initialize_option_handler(ui::Control* c, OptionHandler* optionHandler) { 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("max_open_files", new OptionHandlerInt(c, &apply_max_open_files, &validate_fd)); optionHandler->insert("directory", new OptionHandlerDownloadString(dsm, &apply_download_directory, &validate_directory)); @@ -243,6 +244,9 @@ main(int argc, char** argv) { void do_panic(int signum) { + // Use the default signal handler in the future to avoid infint + // loops. + SignalHandler::set_default(signum); display::Canvas::cleanup(); std::cout << "Signal " << (signum == SIGSEGV ? "SIGSEGV" : "SIGBUS") << " recived, dumping stack:" << std::endl; diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc index 4b8626c9..74e40c43 100644 --- a/src/option_handler_rules.cc +++ b/src/option_handler_rules.cc @@ -63,6 +63,11 @@ validate_read_ahead(int arg) { return arg >= 1 && arg < 64; } +bool +validate_fd(int arg) { + return arg >= 10 && arg < 1024; +} + void apply_download_min_peers(core::Download* d, int arg) { d->get_download().set_peers_min(arg); @@ -100,6 +105,11 @@ apply_hash_read_ahead(ui::Control* m, int arg) { torrent::set_hash_read_ahead(arg << 20); } +void +apply_max_open_files(ui::Control* m, int arg) { + torrent::set_max_open_files(arg); +} + void apply_bind(ui::Control* m, const std::string& arg) { torrent::set_bind(arg); diff --git a/src/option_handler_rules.h b/src/option_handler_rules.h index 7f4fca6b..2932a5d0 100644 --- a/src/option_handler_rules.h +++ b/src/option_handler_rules.h @@ -41,6 +41,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); +bool validate_fd(int arg); void apply_download_min_peers(core::Download* d, int arg); void apply_download_max_peers(core::Download* d, int arg); @@ -52,6 +53,7 @@ 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_max_open_files(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);