소스 검색

For speed, you *need* multiple downloads per host.

Jay Freeman (saurik) 9 년 전
부모
커밋
70aa55819c
1개의 변경된 파일18개의 추가작업 그리고 0개의 파일을 삭제
  1. 18 0
      apt-pkg/acquire.cc

+ 18 - 0
apt-pkg/acquire.cc

@@ -429,6 +429,24 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config)
    } else
    {
       FullQueueName = AccessSchema + U.Host;
+
+      int parallel(_config->FindI("Acquire::"+U.Access+"::MaxParallel",8));
+      if (parallel > 0) {
+	 typedef map<string, int> indexmap;
+	 static indexmap indices;
+
+	 pair<indexmap::iterator, bool> cache(indices.insert(indexmap::value_type(FullQueueName, -1)));
+	 if (cache.second || cache.first->second == -1) {
+	    int &index(indices[U.Access]);
+	    if (index >= parallel)
+	       index = 0;
+	    cache.first->second = index++;
+	 }
+
+	 ostringstream value;
+	 value << U.Access << "::" << cache.first->second;
+	 FullQueueName = value.str();
+      }
    }
    unsigned int Instances = 0, SchemaLength = AccessSchema.length();