]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire.cc
debListParser: Convert another ParseDepends to StringView
[apt.git] / apt-pkg / acquire.cc
index b229a61b62297739accc7c8786b5a2af7576905b..7a483f2727fdbb83d9c45a3e4fbe262e8dc341c8 100644 (file)
@@ -351,8 +351,28 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config)
    if (Config->SingleInstance == true || QueueMode == QueueAccess)
       return U.Access;
 
-   string AccessSchema = U.Access + ':',
-       FullQueueName = AccessSchema + U.Host;
+   string AccessSchema = U.Access + ':';
+       string FullQueueName;
+
+   if (U.Host.empty())
+   {
+      long randomQueue = random();
+#ifdef _SC_NPROCESSORS_ONLN
+      long cpuCount = sysconf(_SC_NPROCESSORS_ONLN) * 2;
+#else
+      long cpuCount = _config->FindI("Acquire::QueueHost::Limit",10);
+#endif
+      if (cpuCount > 0)
+         randomQueue %= cpuCount;
+
+      strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), randomQueue);
+      if (Debug) {
+         clog << "Chose random queue " << FullQueueName << " for " << Uri << endl;
+      }
+   } else
+   {
+      FullQueueName = AccessSchema + U.Host;
+   }
    unsigned int Instances = 0, SchemaLength = AccessSchema.length();
 
    Queue *I = Queues;
@@ -730,7 +750,7 @@ bool pkgAcquire::Clean(string Dir)
 /* This is the total number of bytes needed */
 APT_PURE unsigned long long pkgAcquire::TotalNeeded()
 {
-   return std::accumulate(ItemsBegin(), ItemsEnd(), 0,
+   return std::accumulate(ItemsBegin(), ItemsEnd(), 0llu,
       [](unsigned long long const T, Item const * const I) {
         return T + I->FileSize;
    });
@@ -741,7 +761,7 @@ APT_PURE unsigned long long pkgAcquire::TotalNeeded()
 /* This is the number of bytes that is not local */
 APT_PURE unsigned long long pkgAcquire::FetchNeeded()
 {
-   return std::accumulate(ItemsBegin(), ItemsEnd(), 0,
+   return std::accumulate(ItemsBegin(), ItemsEnd(), 0llu,
       [](unsigned long long const T, Item const * const I) {
         if (I->Local == false)
            return T + I->FileSize;
@@ -755,7 +775,7 @@ APT_PURE unsigned long long pkgAcquire::FetchNeeded()
 /* This is the number of bytes that is not local */
 APT_PURE unsigned long long pkgAcquire::PartialPresent()
 {
-   return std::accumulate(ItemsBegin(), ItemsEnd(), 0,
+   return std::accumulate(ItemsBegin(), ItemsEnd(), 0llu,
       [](unsigned long long const T, Item const * const I) {
         if (I->Local == false)
            return T + I->PartialSize;