]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire.cc
debian/control: Set Standards-Version to 3.9.7
[apt.git] / apt-pkg / acquire.cc
index a86bcef1aba1c8dde630014d337a99cf8234b3b6..17ee691d72715580b3679c33cf1649550fb9c56f 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;
@@ -507,7 +527,11 @@ static void CheckDropPrivsMustBeDisabled(pkgAcquire const &Fetcher)
 
    struct passwd const * const pw = getpwnam(SandboxUser.c_str());
    if (pw == NULL)
+   {
+      _error->Warning(_("No sandbox user '%s' on the system, can not drop privileges"), SandboxUser.c_str());
+      _config->Set("APT::Sandbox::User", "");
       return;
+   }
 
    gid_t const old_euid = geteuid();
    gid_t const old_egid = getegid();
@@ -535,7 +559,7 @@ static void CheckDropPrivsMustBeDisabled(pkgAcquire const &Fetcher)
        I != Fetcher.ItemsEnd(); ++I)
    {
       // no need to drop privileges for a complete file
-      if ((*I)->Complete == true)
+      if ((*I)->Complete == true || (*I)->Status != pkgAcquire::Item::StatIdle)
         continue;
 
       // if destination file is inaccessible all hope is lost for privilege dropping
@@ -726,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;
    });
@@ -737,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;
@@ -751,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;
@@ -815,9 +839,8 @@ bool pkgAcquire::Queue::Enqueue(ItemDesc &Item)
 {
    QItem **I = &Items;
    // move to the end of the queue and check for duplicates here
-   HashStringList const hsl = Item.Owner->GetExpectedHashes();
    for (; *I != 0; I = &(*I)->Next)
-      if (Item.URI == (*I)->URI || hsl == (*I)->Owner->GetExpectedHashes())
+      if (Item.URI == (*I)->URI)
       {
         if (_config->FindB("Debug::pkgAcquire::Worker",false) == true)
            std::cerr << " @ Queue: Action combined for " << Item.URI << " and " << (*I)->URI << std::endl;