Sfoglia il codice sorgente

2010-03-30 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	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
Tatsuhiro Tsujikawa 15 anni fa
parent
commit
68156ef258
9 ha cambiato i file con 96 aggiunte e 4 eliminazioni
  1. 11 0
      ChangeLog
  2. 14 0
      doc/aria2c.1
  3. 20 1
      doc/aria2c.1.html
  4. 11 0
      doc/aria2c.1.txt
  5. 18 0
      src/OptionHandlerFactory.cc
  6. 6 3
      src/TrackerWatcherCommand.cc
  7. 4 0
      src/prefs.cc
  8. 4 0
      src/prefs.h
  9. 8 0
      src/usage_text.h

+ 11 - 0
ChangeLog

@@ -1,3 +1,14 @@
+2010-03-30  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	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  <t-tujikawa@users.sourceforge.net>
 2010-03-30  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 
 	Documented that specifying --seed-time=0 disables seeding after
 	Documented that specifying --seed-time=0 disables seeding after

+ 14 - 0
doc/aria2c.1

@@ -695,6 +695,14 @@ is given, this feature is disabled\&. Default:
 \fI0\fR
 \fI0\fR
 .RE
 .RE
 .PP
 .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
 \fB\-\-bt\-tracker\-interval\fR=SEC
 .RS 4
 .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
 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
 \fI0\fR
 .RE
 .RE
 .PP
 .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
 \fB\-\-dht\-entry\-point\fR=HOST:PORT
 .RS 4
 .RS 4
 Set host and port as an entry point to DHT network\&.
 Set host and port as an entry point to DHT network\&.

+ 20 - 1
doc/aria2c.1.html

@@ -1433,6 +1433,17 @@ writes the piece to the appropriate files.</td>
 </p>
 </p>
 </dd>
 </dd>
 <dt class="hdlist1">
 <dt class="hdlist1">
+<strong>--bt-tracker-connect-timeout</strong>=SEC
+</dt>
+<dd>
+<p>
+  Set the connect timeout in seconds to establish connection to
+  tracker. After the connection is established, this option makes no
+  effect and <strong>--bt-tracker-timeout</strong> option is used instead.  Default:
+  <em>60</em>
+</p>
+</dd>
+<dt class="hdlist1">
 <strong>--bt-tracker-interval</strong>=SEC
 <strong>--bt-tracker-interval</strong>=SEC
 </dt>
 </dt>
 <dd>
 <dd>
@@ -1445,6 +1456,14 @@ writes the piece to the appropriate files.</td>
 </p>
 </p>
 </dd>
 </dd>
 <dt class="hdlist1">
 <dt class="hdlist1">
+<strong>--bt-tracker-timeout</strong>=SEC
+</dt>
+<dd>
+<p>
+  Set timeout in seconds. Default: <em>60</em>
+</p>
+</dd>
+<dt class="hdlist1">
 <strong>--dht-entry-point</strong>=HOST:PORT
 <strong>--dht-entry-point</strong>=HOST:PORT
 </dt>
 </dt>
 <dd>
 <dd>
@@ -4057,7 +4076,7 @@ files in the program, then also delete it here.</p></div>
 <div id="footnotes"><hr /></div>
 <div id="footnotes"><hr /></div>
 <div id="footer">
 <div id="footer">
 <div id="footer-text">
 <div id="footer-text">
-Last updated 2010-03-30 21:50:17 JST
+Last updated 2010-03-30 23:12:40 JST
 </div>
 </div>
 </div>
 </div>
 </body>
 </body>

+ 11 - 0
doc/aria2c.1.txt

@@ -492,6 +492,13 @@ BitTorrent Specific Options
   Stop BitTorrent download if download speed is 0 in consecutive SEC
   Stop BitTorrent download if download speed is 0 in consecutive SEC
   seconds. If '0' is given, this feature is disabled.  Default: '0'
   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::
 *--bt-tracker-interval*=SEC::
   Set the interval in seconds between tracker requests. This
   Set the interval in seconds between tracker requests. This
   completely overrides interval value and aria2 just uses this value
   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
   tracker. If '0' is set, aria2 determines interval based on the
   response of tracker and the download progress.  Default: '0'
   response of tracker and the download progress.  Default: '0'
 
 
+*--bt-tracker-timeout*=SEC::
+
+  Set timeout in seconds. Default: '60'
+
 *--dht-entry-point*=HOST:PORT::
 *--dht-entry-point*=HOST:PORT::
   Set host and port as an entry point to DHT network.
   Set host and port as an entry point to DHT network.
 
 

+ 18 - 0
src/OptionHandlerFactory.cc

@@ -1198,6 +1198,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
     op->hide();
     op->hide();
     handlers.push_back(op);
     handlers.push_back(op);
   }
   }
+  {
+    SharedHandle<NumberOptionHandler> 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<NumberOptionHandler> op(new NumberOptionHandler
     SharedHandle<NumberOptionHandler> op(new NumberOptionHandler
                                          (PREF_BT_TRACKER_INTERVAL,
                                          (PREF_BT_TRACKER_INTERVAL,
@@ -1207,6 +1216,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
     op->addTag(TAG_BITTORRENT);
     op->addTag(TAG_BITTORRENT);
     handlers.push_back(op);
     handlers.push_back(op);
   }
   }
+  {
+    SharedHandle<NumberOptionHandler> op(new NumberOptionHandler
+                                         (PREF_BT_TRACKER_TIMEOUT,
+                                          TEXT_BT_TRACKER_TIMEOUT,
+                                          "60",
+                                          1, 600));
+    op->addTag(TAG_BITTORRENT);
+    handlers.push_back(op);
+  }
   {
   {
     SharedHandle<OptionHandler> op(new HostPortOptionHandler
     SharedHandle<OptionHandler> op(new HostPortOptionHandler
                                    (PREF_DHT_ENTRY_POINT,
                                    (PREF_DHT_ENTRY_POINT,

+ 6 - 3
src/TrackerWatcherCommand.cc

@@ -217,8 +217,6 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri)
   std::vector<std::string> uris;
   std::vector<std::string> uris;
   uris.push_back(uri);
   uris.push_back(uri);
   SharedHandle<RequestGroup> rg(new RequestGroup(getOption()));
   SharedHandle<RequestGroup> 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(backupTrackerIsAvailable(_requestGroup->getDownloadContext())) {
     if(logger->debug()) {
     if(logger->debug()) {
       logger->debug("This is multi-tracker announce.");
       logger->debug("This is multi-tracker announce.");
@@ -228,11 +226,16 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri)
       logger->debug("This is single-tracker announce.");
       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");
   rg->getOption()->put(PREF_MAX_TRIES, "2");
   // TODO When dry-run mode becomes available in BitTorrent, set
   // TODO When dry-run mode becomes available in BitTorrent, set
   // PREF_DRY_RUN=false too.
   // PREF_DRY_RUN=false too.
   rg->getOption()->put(PREF_USE_HEAD, V_FALSE);
   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]");
   static const std::string TRACKER_ANNOUNCE_FILE("[tracker.announce]");
   SharedHandle<DownloadContext> dctx
   SharedHandle<DownloadContext> dctx
     (new DownloadContext(getOption()->getAsInt(PREF_SEGMENT_SIZE),
     (new DownloadContext(getOption()->getAsInt(PREF_SEGMENT_SIZE),

+ 4 - 0
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");
 const std::string PREF_BT_ENABLE_LPD("bt-enable-lpd");
 // values: string
 // values: string
 const std::string PREF_BT_LPD_INTERFACE("bt-lpd-interface");
 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
  * Metalink related preferences

+ 4 - 0
src/prefs.h

@@ -338,6 +338,10 @@ extern const std::string PREF_BT_METADATA_ONLY;
 extern const std::string PREF_BT_ENABLE_LPD;
 extern const std::string PREF_BT_ENABLE_LPD;
 // values: string
 // values: string
 extern const std::string PREF_BT_LPD_INTERFACE;
 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
  * Metalink related preferences

+ 8 - 0
src/usage_text.h

@@ -657,3 +657,11 @@
     "                              is 0, aria2 downloads file from scratch when all\n" \
     "                              is 0, aria2 downloads file from scratch when all\n" \
     "                              given URIs do not support resume.\n" \
     "                              given URIs do not support resume.\n" \
     "                              See --always-resume option.")
     "                              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.")