diff --git a/ChangeLog b/ChangeLog index fd24d8c4..dc539ca0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-02-01 Tatsuhiro Tsujikawa + + Added _maxTries property to RequestGroup and assign the option + value of PREF_MAX_TRIES to it. AbstractCommand now looks up + RequestGroup::getMaxTries() instead of + Option::getAsInt(PREF_MAX_TRIES). + * src/AbstractCommand.cc + * src/RequestGroup.cc + * src/RequestGroup.h + 2009-02-01 Tatsuhiro Tsujikawa Applied AdaptiveURISelector-timeout patch from Pascal Rigaux at diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index e34816bd..c2d440b1 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -165,8 +165,8 @@ bool AbstractCommand::execute() { logger->info(MSG_RESTARTING_DOWNLOAD, err, cuid, req->getUrl().c_str()); req->addTryCount(); req->resetRedirectCount(); - bool isAbort = e->option->getAsInt(PREF_MAX_TRIES) != 0 && - req->getTryCount() >= (unsigned int)e->option->getAsInt(PREF_MAX_TRIES); + bool isAbort = _requestGroup->getMaxTries() != 0 && + req->getTryCount() >= _requestGroup->getMaxTries(); if(isAbort) { onAbort(); } diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 9f6f9e48..493e20d3 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -127,6 +127,7 @@ RequestGroup::RequestGroup(const Option* option, _lastModifiedTime(Time::null()), _fileNotFoundCount(0), _timeout(option->getAsInt(PREF_TIMEOUT)), + _maxTries(option->getAsInt(PREF_MAX_TRIES)), _inMemoryDownload(false), _option(option), _logger(LogFactory::getInstance()) @@ -1144,4 +1145,14 @@ time_t RequestGroup::getTimeout() const return _timeout; } +void RequestGroup::setMaxTries(unsigned int maxTries) +{ + _maxTries = maxTries; +} + +unsigned int RequestGroup::getMaxTries() const +{ + return _maxTries; +} + } // namespace aria2 diff --git a/src/RequestGroup.h b/src/RequestGroup.h index 2edab449..335bc37b 100644 --- a/src/RequestGroup.h +++ b/src/RequestGroup.h @@ -137,6 +137,9 @@ private: // Timeout used for HTTP/FTP downloads. time_t _timeout; + // How many times HTTP/FTP download should retry. + unsigned int _maxTries; + #ifdef ENABLE_BITTORRENT WeakHandle _btRuntime; @@ -431,6 +434,10 @@ public: void setTimeout(time_t timeout); time_t getTimeout() const; + + void setMaxTries(unsigned int maxTries); + + unsigned int getMaxTries() const; }; typedef SharedHandle RequestGroupHandle;