Просмотр исходного кода

2010-07-19 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Metadata download may take very long time. If URIs are
	available, give up metadata download in at most 30 seconds.
	* src/Metalink2RequestGroup.cc
Tatsuhiro Tsujikawa 15 лет назад
Родитель
Сommit
21887ddb7c
2 измененных файлов с 25 добавлено и 0 удалено
  1. 6 0
      ChangeLog
  2. 19 0
      src/Metalink2RequestGroup.cc

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2010-07-19  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Metadata download may take very long time. If URIs are
+	available, give up metadata download in at most 30 seconds.
+	* src/Metalink2RequestGroup.cc
+
 2010-07-19  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Call RequestGroup::setForceHaltRequested(true) from

+ 19 - 0
src/Metalink2RequestGroup.cc

@@ -315,6 +315,25 @@ Metalink2RequestGroup::createRequestGroup
       SharedHandle<Dependency> dep(new BtDependency(rg, torrentRg));
       rg->dependsOn(dep);
       torrentRg->belongsTo(rg->getGID());
+      // metadata download may take very long time. If URIs are
+      // available, give up metadata download in at most 30 seconds.
+      const time_t btStopTimeout = 30;
+      time_t currentBtStopTimeout =
+        torrentRg->getOption()->getAsInt(PREF_BT_STOP_TIMEOUT);
+      if(currentBtStopTimeout == 0 || currentBtStopTimeout > btStopTimeout) {
+        std::vector<SharedHandle<FileEntry> >::const_iterator i;
+        std::vector<SharedHandle<FileEntry> >::const_iterator eoi
+          = dctx->getFileEntries().end();
+        for(i = dctx->getFileEntries().begin(); i != eoi; ++i) {
+          if((*i)->getRemainingUris().empty()) {
+            break;
+          }
+        }
+        if(i == dctx->getFileEntries().end()) {
+          torrentRg->getOption()->put
+            (PREF_BT_STOP_TIMEOUT, util::itos(btStopTimeout));
+        }
+      }
     }
 #endif // ENABLE_BITTORRENT
     groups.push_back(rg);