Browse Source

2009-02-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	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
Tatsuhiro Tsujikawa 16 years ago
parent
commit
1b26827851
4 changed files with 30 additions and 2 deletions
  1. 10 0
      ChangeLog
  2. 2 2
      src/AbstractCommand.cc
  3. 11 0
      src/RequestGroup.cc
  4. 7 0
      src/RequestGroup.h

+ 10 - 0
ChangeLog

@@ -1,3 +1,13 @@
+2009-02-01  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	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  <t-tujikawa@users.sourceforge.net>
 
 	Applied AdaptiveURISelector-timeout patch from Pascal Rigaux at

+ 2 - 2
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();
     }

+ 11 - 0
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

+ 7 - 0
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> _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<RequestGroup> RequestGroupHandle;