From 2170a850a878c428b0cfd487f53f167da7470b50 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 20 Mar 2009 13:44:03 +0000 Subject: [PATCH] 2009-03-20 Tatsuhiro Tsujikawa Added an option to specify the interval between tracker requests. If non-zero value is specified, aria2 uses it and ignores the interval value in the response of tracker. If zero is specified, aria2 determines the inteval value based on the tarcker response and download progress. * src/DefaultBtAnnounce.cc * src/DefaultBtAnnounce.h * src/OptionHandlerFactory.cc * src/RequestGroup.cc * src/prefs.cc * src/prefs.h * src/usage_text.h --- ChangeLog | 15 +++++++++++++++ src/DefaultBtAnnounce.cc | 5 ++++- src/DefaultBtAnnounce.h | 6 ++++++ src/OptionHandlerFactory.cc | 9 +++++++++ src/RequestGroup.cc | 2 ++ src/prefs.cc | 2 ++ src/prefs.h | 2 ++ src/usage_text.h | 8 ++++++++ 8 files changed, 48 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 49bff646..734d2323 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-03-20 Tatsuhiro Tsujikawa + + Added an option to specify the interval between tracker requests. + If non-zero value is specified, aria2 uses it and ignores the + interval value in the response of tracker. If zero is specified, + aria2 determines the inteval value based on the tarcker response + and download progress. + * src/DefaultBtAnnounce.cc + * src/DefaultBtAnnounce.h + * src/OptionHandlerFactory.cc + * src/RequestGroup.cc + * src/prefs.cc + * src/prefs.h + * src/usage_text.h + 2009-03-20 Tatsuhiro Tsujikawa Added operator+=, operator-=, operator- diff --git a/src/DefaultBtAnnounce.cc b/src/DefaultBtAnnounce.cc index 05ea4cef..5086532b 100644 --- a/src/DefaultBtAnnounce.cc +++ b/src/DefaultBtAnnounce.cc @@ -60,6 +60,7 @@ DefaultBtAnnounce::DefaultBtAnnounce(const BtContextHandle& btContext, trackers(0), interval(DEFAULT_ANNOUNCE_INTERVAL), minInterval(DEFAULT_ANNOUNCE_INTERVAL), + _userDefinedInterval(0), complete(0), incomplete(0), announceList(btContext->getAnnounceTiers()), @@ -80,7 +81,9 @@ void DefaultBtAnnounce::generateKey() } bool DefaultBtAnnounce::isDefaultAnnounceReady() { - return (trackers == 0 && prevAnnounceTime.elapsed(minInterval) && + return (trackers == 0 && + prevAnnounceTime.elapsed(_userDefinedInterval==0? + minInterval:_userDefinedInterval) && !announceList.allTiersFailed()); } diff --git a/src/DefaultBtAnnounce.h b/src/DefaultBtAnnounce.h index dac1c4cc..053bb23a 100644 --- a/src/DefaultBtAnnounce.h +++ b/src/DefaultBtAnnounce.h @@ -56,6 +56,7 @@ private: Time prevAnnounceTime; time_t interval; time_t minInterval; + time_t _userDefinedInterval; unsigned int complete; unsigned int incomplete; AnnounceList announceList; @@ -142,6 +143,11 @@ public: { return trackerId; } + + void setUserDefinedInterval(time_t interval) + { + _userDefinedInterval = interval; + } }; } // namespace aria2 diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index e59c777f..84625d61 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -930,6 +930,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() op->hide(); handlers.push_back(op); } + { + SharedHandle op(new NumberOptionHandler + (PREF_BT_TRACKER_INTERVAL, + TEXT_BT_TRACKER_INTERVAL, + "0", + 0)); + op->addTag(TAG_BITTORRENT); + handlers.push_back(op); + } { SharedHandle op(new HostPortOptionHandler (PREF_DHT_ENTRY_POINT, diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 4180f1c8..09299505 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -267,6 +267,8 @@ void RequestGroup::createInitialCommand(std::deque& commands, btAnnounce->setBtRuntime(btRuntime); btAnnounce->setPieceStorage(_pieceStorage); btAnnounce->setPeerStorage(peerStorage); + btAnnounce->setUserDefinedInterval + (_option->getAsInt(PREF_BT_TRACKER_INTERVAL)); btRegistry->registerBtAnnounce(btContext->getInfoHashAsString(), btAnnounce); btAnnounce->shuffleAnnounce(); diff --git a/src/prefs.cc b/src/prefs.cc index af4660a4..9ef9ed07 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -289,6 +289,8 @@ const std::string PREF_BT_MAX_PEERS("bt-max-peers"); const std::string PREF_BT_EXTERNAL_IP("bt-external-ip"); // values: 1*digit '=' a string that your file system recognizes as a file name. const std::string PREF_INDEX_OUT("index-out"); +// values: 1*digit +const std::string PREF_BT_TRACKER_INTERVAL("bt-tracker-interval"); /** * Metalink related preferences diff --git a/src/prefs.h b/src/prefs.h index c75f2473..3c45e39f 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -293,6 +293,8 @@ extern const std::string PREF_BT_MAX_PEERS; extern const std::string PREF_BT_EXTERNAL_IP; // values: 1*digit '=' a string that your file system recognizes as a file name. extern const std::string PREF_INDEX_OUT; +// values: 1*digit +extern const std::string PREF_BT_TRACKER_INTERVAL; /** * Metalink related preferences diff --git a/src/usage_text.h b/src/usage_text.h index d16cb319..222f2b4e 100644 --- a/src/usage_text.h +++ b/src/usage_text.h @@ -505,3 +505,11 @@ _(" --dry-run[=true|false] If true is given, aria2 just checks whether the " data. This option has effect on HTTP/FTP download.\n"\ " BitTorrent downloads are canceled if true is\n"\ " specified.") +#define TEXT_BT_TRACKER_INTERVAL \ +_(" --bt-tracker-interval=SEC Set the interval in seconds between tracker\n"\ + " requests. This completely overrides interval value\n"\ + " and aria2 just uses this value and ignores the\n"\ + " minInterval and interval value in the response of\n"\ + " tracker. If 0 is set, aria2 determines interval\n"\ + " based on the response of tracker and the download\n"\ + " progress.")