]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire.cc
Bug #807012 also involves package dependencies :/.
[apt.git] / apt-pkg / acquire.cc
index 2ad6bc47f91c3a846ce658faeaab84acd37eda6c..4ccfa26052a5a2488a072c143674801f393d7f96 100644 (file)
@@ -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();
 
@@ -1154,7 +1172,7 @@ APT_PURE unsigned long long pkgAcquire::Queue::QItem::GetMaximumSize() const      /*{
    return Maximum;
 }
                                                                        /*}}}*/
-APT_PURE int pkgAcquire::Queue::QItem::GetPriority() const     /*{{{*/
+APT_PURE int pkgAcquire::Queue::QItem::GetPriority() const             /*{{{*/
 {
    int Priority = 0;
    for (auto const &O: Owners)