]> git.saurik.com Git - apt-legacy.git/blobdiff - apt-pkg/acquire.cc
Fixed Dl-Limit (long standing APT bug that they won't acknowledge), specified error...
[apt-legacy.git] / apt-pkg / acquire.cc
index fff1b2b6ad379b28603de987933b4523dc5c3f36..b1463dc67fc2f0efa32520ba85c8684192200fd3 100644 (file)
@@ -238,9 +238,27 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config)
    /* Single-Instance methods get exactly one queue per URI. This is
       also used for the Access queue method  */
    if (Config->SingleInstance == true || QueueMode == QueueAccess)
-       return U.Access;
+      return U.Access;
+   string name(U.Access + ':' + U.Host);
 
-   return U.Access + ':' + U.Host;
+   int parallel(_config->FindI("Acquire::"+U.Access+"::MaxParallel",0));
+   if (parallel <= 0)
+      return name;
+
+   typedef map<string, int> indexmap;
+   static indexmap indices;
+
+   pair<indexmap::iterator, bool> cache(indices.insert(indexmap::value_type(name, -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;
+   return value.str();
 }
                                                                        /*}}}*/
 // Acquire::GetConfig - Fetch the configuration information            /*{{{*/
@@ -268,7 +286,7 @@ pkgAcquire::MethodConfig *pkgAcquire::GetConfig(string Access)
       return 0;
 
    /* if a method uses DownloadLimit, we switch to SingleInstance mode */
-   if(_config->FindI("Acquire::"+Access+"::DlLimit",0) > 0)
+   if(_config->FindI("Acquire::"+Access+"::Dl-Limit",0) > 0)
       Conf->SingleInstance = true;
     
    return Conf;