From 68156ef258079c50965b86483ea7b119a82c93ad Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 30 Mar 2010 14:17:16 +0000 Subject: [PATCH] 2010-03-30 Tatsuhiro Tsujikawa Added --bt-tracker-connect-timeout and --bt-tracker-timeout option. * doc/aria2c.1.txt * src/OptionHandlerFactory.cc * src/TrackerWatcherCommand.cc * src/prefs.cc * src/prefs.h * src/usage_text.h --- ChangeLog | 11 +++++++++++ doc/aria2c.1 | 14 ++++++++++++++ doc/aria2c.1.html | 21 ++++++++++++++++++++- doc/aria2c.1.txt | 11 +++++++++++ src/OptionHandlerFactory.cc | 18 ++++++++++++++++++ src/TrackerWatcherCommand.cc | 9 ++++++--- src/prefs.cc | 4 ++++ src/prefs.h | 4 ++++ src/usage_text.h | 8 ++++++++ 9 files changed, 96 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 847f6656..4b924077 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-03-30 Tatsuhiro Tsujikawa + + Added --bt-tracker-connect-timeout and --bt-tracker-timeout + option. + * doc/aria2c.1.txt + * src/OptionHandlerFactory.cc + * src/TrackerWatcherCommand.cc + * src/prefs.cc + * src/prefs.h + * src/usage_text.h + 2010-03-30 Tatsuhiro Tsujikawa Documented that specifying --seed-time=0 disables seeding after diff --git a/doc/aria2c.1 b/doc/aria2c.1 index ede4733e..259680be 100644 --- a/doc/aria2c.1 +++ b/doc/aria2c.1 @@ -695,6 +695,14 @@ is given, this feature is disabled\&. Default: \fI0\fR .RE .PP +\fB\-\-bt\-tracker\-connect\-timeout\fR=SEC +.RS 4 +Set the connect timeout in seconds to establish connection to tracker\&. After the connection is established, this option makes no effect and +\fB\-\-bt\-tracker\-timeout\fR +option is used instead\&. Default: +\fI60\fR +.RE +.PP \fB\-\-bt\-tracker\-interval\fR=SEC .RS 4 Set the interval in seconds between tracker requests\&. This completely overrides interval value and aria2 just uses this value and ignores the min interval and interval value in the response of tracker\&. If @@ -703,6 +711,12 @@ is set, aria2 determines interval based on the response of tracker and the downl \fI0\fR .RE .PP +\fB\-\-bt\-tracker\-timeout\fR=SEC +.RS 4 +Set timeout in seconds\&. Default: +\fI60\fR +.RE +.PP \fB\-\-dht\-entry\-point\fR=HOST:PORT .RS 4 Set host and port as an entry point to DHT network\&. diff --git a/doc/aria2c.1.html b/doc/aria2c.1.html index 645b59b2..37ab5da3 100644 --- a/doc/aria2c.1.html +++ b/doc/aria2c.1.html @@ -1433,6 +1433,17 @@ writes the piece to the appropriate files.

+--bt-tracker-connect-timeout=SEC +
+
+

+ Set the connect timeout in seconds to establish connection to + tracker. After the connection is established, this option makes no + effect and --bt-tracker-timeout option is used instead. Default: + 60 +

+
+
--bt-tracker-interval=SEC
@@ -1445,6 +1456,14 @@ writes the piece to the appropriate files.

+--bt-tracker-timeout=SEC +
+
+

+ Set timeout in seconds. Default: 60 +

+
+
--dht-entry-point=HOST:PORT
@@ -4057,7 +4076,7 @@ files in the program, then also delete it here.


diff --git a/doc/aria2c.1.txt b/doc/aria2c.1.txt index 98c14015..34e572b3 100644 --- a/doc/aria2c.1.txt +++ b/doc/aria2c.1.txt @@ -492,6 +492,13 @@ BitTorrent Specific Options Stop BitTorrent download if download speed is 0 in consecutive SEC seconds. If '0' is given, this feature is disabled. Default: '0' +*--bt-tracker-connect-timeout*=SEC:: + + Set the connect timeout in seconds to establish connection to + tracker. After the connection is established, this option makes no + effect and *--bt-tracker-timeout* option is used instead. Default: + '60' + *--bt-tracker-interval*=SEC:: Set the interval in seconds between tracker requests. This completely overrides interval value and aria2 just uses this value @@ -499,6 +506,10 @@ BitTorrent Specific Options tracker. If '0' is set, aria2 determines interval based on the response of tracker and the download progress. Default: '0' +*--bt-tracker-timeout*=SEC:: + + Set timeout in seconds. Default: '60' + *--dht-entry-point*=HOST:PORT:: Set host and port as an entry point to DHT network. diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 0df5c502..84c289f1 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -1198,6 +1198,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() op->hide(); handlers.push_back(op); } + { + SharedHandle op(new NumberOptionHandler + (PREF_BT_TRACKER_CONNECT_TIMEOUT, + TEXT_BT_TRACKER_CONNECT_TIMEOUT, + "60", + 1, 600)); + op->addTag(TAG_BITTORRENT); + handlers.push_back(op); + } { SharedHandle op(new NumberOptionHandler (PREF_BT_TRACKER_INTERVAL, @@ -1207,6 +1216,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); handlers.push_back(op); } + { + SharedHandle op(new NumberOptionHandler + (PREF_BT_TRACKER_TIMEOUT, + TEXT_BT_TRACKER_TIMEOUT, + "60", + 1, 600)); + op->addTag(TAG_BITTORRENT); + handlers.push_back(op); + } { SharedHandle op(new HostPortOptionHandler (PREF_DHT_ENTRY_POINT, diff --git a/src/TrackerWatcherCommand.cc b/src/TrackerWatcherCommand.cc index 30dcbbda..3e10b713 100644 --- a/src/TrackerWatcherCommand.cc +++ b/src/TrackerWatcherCommand.cc @@ -217,8 +217,6 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri) std::vector uris; uris.push_back(uri); SharedHandle rg(new RequestGroup(getOption())); - // If backup tracker is available, only try 2 times for each tracker - // and if they all fails, then try next one. if(backupTrackerIsAvailable(_requestGroup->getDownloadContext())) { if(logger->debug()) { logger->debug("This is multi-tracker announce."); @@ -228,11 +226,16 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri) logger->debug("This is single-tracker announce."); } } + // If backup tracker is available, try 2 times for each tracker + // and if they all fails, then try next one. rg->getOption()->put(PREF_MAX_TRIES, "2"); // TODO When dry-run mode becomes available in BitTorrent, set // PREF_DRY_RUN=false too. rg->getOption()->put(PREF_USE_HEAD, V_FALSE); - + // Setting tracker timeouts + rg->setTimeout(rg->getOption()->getAsInt(PREF_BT_TRACKER_TIMEOUT)); + rg->getOption()->put(PREF_CONNECT_TIMEOUT, + rg->getOption()->get(PREF_BT_TRACKER_CONNECT_TIMEOUT)); static const std::string TRACKER_ANNOUNCE_FILE("[tracker.announce]"); SharedHandle dctx (new DownloadContext(getOption()->getAsInt(PREF_SEGMENT_SIZE), diff --git a/src/prefs.cc b/src/prefs.cc index d3caec13..37406885 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -334,6 +334,10 @@ const std::string PREF_BT_METADATA_ONLY("bt-metadata-only"); const std::string PREF_BT_ENABLE_LPD("bt-enable-lpd"); // values: string const std::string PREF_BT_LPD_INTERFACE("bt-lpd-interface"); +// values: 1*digit +const std::string PREF_BT_TRACKER_TIMEOUT("bt-tracker-timeout"); +// values: 1*digit +const std::string PREF_BT_TRACKER_CONNECT_TIMEOUT("bt-tracker-connect-timeout"); /** * Metalink related preferences diff --git a/src/prefs.h b/src/prefs.h index d1b08bd4..99d598cf 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -338,6 +338,10 @@ extern const std::string PREF_BT_METADATA_ONLY; extern const std::string PREF_BT_ENABLE_LPD; // values: string extern const std::string PREF_BT_LPD_INTERFACE; +// values: 1*digit +extern const std::string PREF_BT_TRACKER_TIMEOUT; +// values: 1*digit +extern const std::string PREF_BT_TRACKER_CONNECT_TIMEOUT; /** * Metalink related preferences diff --git a/src/usage_text.h b/src/usage_text.h index 9b8d7fcf..2a35d871 100644 --- a/src/usage_text.h +++ b/src/usage_text.h @@ -657,3 +657,11 @@ " is 0, aria2 downloads file from scratch when all\n" \ " given URIs do not support resume.\n" \ " See --always-resume option.") +#define TEXT_BT_TRACKER_TIMEOUT \ + _(" --bt-tracker-timeout=SEC Set timeout in seconds.") +#define TEXT_BT_TRACKER_CONNECT_TIMEOUT \ + _(" --bt-tracker-connect-timeout=SEC Set the connect timeout in seconds to\n" \ + " establish connection to tracker. After the\n" \ + " connection is established, this option makes no\n" \ + " effect and --bt-tracker-timeout option is used\n" \ + " instead.")