diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire.cc | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 3010f55aa..7a483f272 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -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; |