summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc1
-rw-r--r--apt-pkg/acquire.cc110
-rw-r--r--apt-pkg/algorithms.h2
-rw-r--r--apt-pkg/contrib/cmndline.cc3
-rw-r--r--apt-pkg/contrib/hashes.cc5
-rw-r--r--apt-pkg/contrib/strutl.cc9
-rw-r--r--apt-pkg/deb/deblistparser.cc7
-rw-r--r--apt-pkg/deb/debmetaindex.cc6
-rw-r--r--apt-pkg/edsp/edspindexfile.cc4
-rw-r--r--apt-pkg/packagemanager.cc2
-rw-r--r--apt-pkg/pkgcache.cc2
-rw-r--r--apt-pkg/pkgsystem.h2
-rw-r--r--apt-pkg/sourcelist.cc2
-rw-r--r--apt-pkg/sourcelist.h2
14 files changed, 90 insertions, 67 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index cbfc91007..58bd6475e 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -3382,7 +3382,6 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *const Owner, pkgSourceList *const Sourc
Trusted = false;
StoreFilename.clear();
- std::set<string> targetComponents, targetCodenames, targetSuites;
std::vector<std::unique_ptr<FileFd>> authconfs;
for (auto Vf = Version.FileList(); Vf.end() == false; ++Vf)
{
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 8bb72d549..6cf8b4c83 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -385,75 +385,97 @@ void pkgAcquire::Dequeue(Item *Itm)
return http://foo.org or http */
string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config)
{
+ constexpr int DEFAULT_HOST_LIMIT = 10;
URI U(Uri);
-
- Config = GetConfig(U.Access);
- if (Config == 0)
- return string();
-
- /* Single-Instance methods get exactly one queue per URI. This is
- also used for the Access queue method */
- if (Config->SingleInstance == true || QueueMode == QueueAccess)
+ // Access mode forces all methods to be Single-Instance
+ if (QueueMode == QueueAccess)
return U.Access;
- int Limit = 10;
- string AccessSchema = U.Access + ':';
- string FullQueueName;
+ Config = GetConfig(U.Access);
+ if (Config == nullptr)
+ return {};
+
+ // Single-Instance methods get exactly one queue per URI
+ if (Config->SingleInstance == true)
+ return U.Access;
+ // Host-less methods like rred, store, …
if (U.Host.empty())
{
- long existing = 0;
+ int existing = 0;
// check how many queues exist already and reuse empty ones
+ auto const AccessSchema = U.Access + ':';
for (Queue const *I = Queues; I != 0; I = I->Next)
- if (I->Name.compare(0, AccessSchema.length(), AccessSchema) == 0)
+ if (APT::String::Startswith(I->Name, AccessSchema))
{
if (I->Items == nullptr)
return I->Name;
++existing;
}
+ int const Limit = _config->FindI("Acquire::QueueHost::Limit",
#ifdef _SC_NPROCESSORS_ONLN
- long cpuCount = sysconf(_SC_NPROCESSORS_ONLN) * 2;
+ sysconf(_SC_NPROCESSORS_ONLN) * 2
#else
- long cpuCount = Limit;
+ DEFAULT_HOST_LIMIT
#endif
- Limit = _config->FindI("Acquire::QueueHost::Limit", cpuCount);
+ );
+ // create a new worker if we don't have too many yet
if (Limit <= 0 || existing < Limit)
- strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), existing);
- else
- {
- long const randomQueue = random() % Limit;
- strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), randomQueue);
- }
+ return AccessSchema + std::to_string(existing);
+
+ // find the worker with the least to do
+ // we already established that there are no empty and we can't spawn new
+ Queue const *selected = nullptr;
+ auto selected_backlog = std::numeric_limits<decltype(HashStringList().FileSize())>::max();
+ for (Queue const *Q = Queues; Q != nullptr; Q = Q->Next)
+ if (APT::String::Startswith(Q->Name, AccessSchema))
+ {
+ decltype(selected_backlog) current_backlog = 0;
+ for (auto const *I = Q->Items; I != nullptr; I = I->Next)
+ {
+ auto const hashes = I->Owner->GetExpectedHashes();
+ if (not hashes.empty())
+ current_backlog += hashes.FileSize();
+ else
+ current_backlog += I->Owner->FileSize;
+ }
+ if (current_backlog < selected_backlog)
+ {
+ selected = Q;
+ selected_backlog = current_backlog;
+ }
+ }
- if (Debug)
- clog << "Chose random queue " << FullQueueName << " for " << Uri << endl;
- } else
- {
- Limit = _config->FindI("Acquire::QueueHost::Limit", Limit);
- FullQueueName = AccessSchema + U.Host;
+ if (unlikely(selected == nullptr))
+ return AccessSchema + "0";
+ return selected->Name;
}
- unsigned int Instances = 0, SchemaLength = AccessSchema.length();
-
- Queue *I = Queues;
- for (; I != 0; I = I->Next) {
+ // most methods talking to remotes like http
+ else
+ {
+ auto const FullQueueName = U.Access + ':' + U.Host;
// if the queue already exists, re-use it
- if (I->Name == FullQueueName)
- return FullQueueName;
-
- if (I->Name.compare(0, SchemaLength, AccessSchema) == 0)
- Instances++;
- }
+ for (Queue const *Q = Queues; Q != nullptr; Q = Q->Next)
+ if (Q->Name == FullQueueName)
+ return FullQueueName;
- if (Debug) {
- clog << "Found " << Instances << " instances of " << U.Access << endl;
- }
+ int existing = 0;
+ // check how many queues exist already and reuse empty ones
+ auto const AccessSchema = U.Access + ':';
+ for (Queue const *Q = Queues; Q != nullptr; Q = Q->Next)
+ if (APT::String::Startswith(Q->Name, AccessSchema))
+ ++existing;
- if (Instances >= static_cast<decltype(Instances)>(Limit))
- return U.Access;
+ int const Limit = _config->FindI("Acquire::QueueHost::Limit", DEFAULT_HOST_LIMIT);
+ // if we have too many hosts open use a single generic for the rest
+ if (existing >= Limit)
+ return U.Access;
- return FullQueueName;
+ // we can still create new named queues
+ return FullQueueName;
+ }
}
/*}}}*/
// Acquire::GetConfig - Fetch the configuration information /*{{{*/
diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h
index 21d79367b..789f304a9 100644
--- a/apt-pkg/algorithms.h
+++ b/apt-pkg/algorithms.h
@@ -16,7 +16,7 @@
pkgFixBroken corrects a broken system so that it is in a sane state.
- pkgAllUpgrade attempts to upgade as many packages as possible but
+ pkgAllUpgrade attempts to upgrade as many packages as possible but
without installing new packages.
The problem resolver class contains a number of complex algorithms
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index b2a96cadf..3b844edc2 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -300,7 +300,8 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
// Skip the leading dash
const char *J = argv[I];
- for (; *J != 0 && *J == '-'; J++);
+ for (; *J == '-'; J++)
+ ;
const char *JEnd = strchr(J, '-');
if (JEnd != NULL)
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index d03fb6083..366133b02 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -169,10 +169,7 @@ bool HashStringList::usable() const /*{{{*/
if (forcedType.empty() == true)
{
// See if there is at least one usable hash
- for (auto const &hs: list)
- if (hs.usable())
- return true;
- return false;
+ return std::any_of(list.begin(), list.end(), [](auto const &hs) { return hs.usable(); });
}
return find(forcedType) != NULL;
}
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index e02067e13..860e3fe47 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -239,7 +239,8 @@ bool ParseQuoteWord(const char *&String,string &Res)
{
// Skip leading whitespace
const char *C = String;
- for (;*C != 0 && *C == ' '; C++);
+ for (; *C == ' '; C++)
+ ;
if (*C == 0)
return false;
@@ -287,7 +288,8 @@ bool ParseQuoteWord(const char *&String,string &Res)
Res = Buffer;
// Skip ending white space
- for (;*C != 0 && isspace(*C) != 0; C++);
+ for (; isspace(*C) != 0; C++)
+ ;
String = C;
return true;
}
@@ -300,7 +302,8 @@ bool ParseCWord(const char *&String,string &Res)
{
// Skip leading whitespace
const char *C = String;
- for (;*C != 0 && *C == ' '; C++);
+ for (; *C == ' '; C++)
+ ;
if (*C == 0)
return false;
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 832e3948d..75fc2d242 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -820,7 +820,8 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
Start = ParseDepends(Start, Stop, Package, Version, Op, false, false, false, myArch);
if (Start == 0)
- return _error->Error("Problem parsing dependency %zu",static_cast<size_t>(Key)); // TODO
+ return _error->Error("Problem parsing dependency %zu of %s:%s=%s", static_cast<size_t>(Key), // TODO
+ Ver.ParentPkg().Name(), Ver.Arch(), Ver.VerStr());
size_t const found = Package.rfind(':');
if (found == string::npos)
@@ -888,9 +889,9 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
Start = ParseDepends(Start,Stop,Package,Version,Op, false, false, false);
const size_t archfound = Package.rfind(':');
if (Start == 0)
- return _error->Error("Problem parsing Provides line");
+ return _error->Error("Problem parsing Provides line of %s:%s=%s", Ver.ParentPkg().Name(), Ver.Arch(), Ver.VerStr());
if (unlikely(Op != pkgCache::Dep::NoOp && Op != pkgCache::Dep::Equals)) {
- _error->Warning("Ignoring Provides line with non-equal DepCompareOp for package %s", Package.to_string().c_str());
+ _error->Warning("Ignoring non-equal Provides for package %s in %s:%s=%s", Package.to_string().c_str(), Ver.ParentPkg().Name(), Ver.Arch(), Ver.VerStr());
} else if (archfound != string::npos) {
StringView spzArch = Package.substr(archfound + 1);
if (spzArch != "any")
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 71e047257..a88b19807 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -986,7 +986,7 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
return std::find(minus.begin(), minus.end(), v) != minus.end();
}), Values.end());
}
- return Values;
+ return std::move(Values);
}
static std::vector<std::string> parsePlusMinusOptions(std::string const &Name,
std::map<std::string, std::string> const &Options, std::vector<std::string> const &defaultValues)
@@ -1095,8 +1095,8 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
{
std::vector<std::string> ret;
ret.reserve(Options.size());
- for (auto &&O: Options)
- ret.emplace_back(O.first);
+ std::transform(Options.begin(), Options.end(), std::back_inserter(ret),
+ [](auto &&O) { return O.first; });
std::sort(ret.begin(), ret.end());
return ret;
}
diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc
index 1a8af89f0..faade6e0a 100644
--- a/apt-pkg/edsp/edspindexfile.cc
+++ b/apt-pkg/edsp/edspindexfile.cc
@@ -96,7 +96,7 @@ class APT_HIDDEN edspIFType: public pkgIndexFile::Type
public:
virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &) const APT_OVERRIDE
{
- // we don't have a record parser for this type as the file is not presistent
+ // we don't have a record parser for this type as the file is not persistent
return NULL;
};
edspIFType() {Label = "EDSP scenario file";};
@@ -112,7 +112,7 @@ class APT_HIDDEN eippIFType: public pkgIndexFile::Type
public:
virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &) const APT_OVERRIDE
{
- // we don't have a record parser for this type as the file is not presistent
+ // we don't have a record parser for this type as the file is not persistent
return NULL;
};
eippIFType() {Label = "EIPP scenario file";};
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 21905c7b6..e58589d73 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -918,7 +918,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
else
{
if (Debug)
- clog << OutputInDepth(Depth) << "So temprorary remove/deconfigure " << ConflictPkg.FullName() << " to satisfy " << APT::PrettyDep(&Cache, End) << endl;
+ clog << OutputInDepth(Depth) << "So temporary remove/deconfigure " << ConflictPkg.FullName() << " to satisfy " << APT::PrettyDep(&Cache, End) << endl;
if (EarlyRemove(ConflictPkg, &End) == false)
return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 2);
}
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index cbb67820a..ba9a39f13 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -128,7 +128,7 @@ bool pkgCache::Header::CheckSizes(Header &Against) const
pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map), VS(nullptr), d(NULL)
{
// call getArchitectures() with cached=false to ensure that the
- // architectures cache is re-evaulated. this is needed in cases
+ // architectures cache is re-evaluated. this is needed in cases
// when the APT::Architecture field changes between two cache creations
MultiArchEnabled = APT::Configuration::getArchitectures(false).size() > 1;
if (DoMap == true)
diff --git a/apt-pkg/pkgsystem.h b/apt-pkg/pkgsystem.h
index 1be2668ff..051b11ac2 100644
--- a/apt-pkg/pkgsystem.h
+++ b/apt-pkg/pkgsystem.h
@@ -83,7 +83,7 @@ class pkgSystem
virtual bool FindIndex(pkgCache::PkgFileIterator File,
pkgIndexFile *&Found) const = 0;
- /* Evauluate how 'right' we are for this system based on the filesystem
+ /* Evaluate how 'right' we are for this system based on the filesystem
etc.. */
virtual signed Score(Configuration const &/*Cnf*/) {
return 0;
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc
index eef4d8a7f..cd7dbce9c 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -215,7 +215,7 @@ bool pkgSourceList::Type::ParseLine(vector<metaIndex *> &List,
// get one option, e.g. option1=value1
string option;
if (ParseQuoteWord(Buffer,option) == false)
- return _error->Error(_("Malformed entry %u in %s file %s (%s)"), CurLine, "list", File.c_str(), "[option] unparseable");
+ return _error->Error(_("Malformed entry %u in %s file %s (%s)"), CurLine, "list", File.c_str(), "[option] unparsable");
if (option.length() < 3)
return _error->Error(_("Malformed entry %u in %s file %s (%s)"), CurLine, "list", File.c_str(), "[option] too short");
diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h
index efbf4bfbc..91dc03dcf 100644
--- a/apt-pkg/sourcelist.h
+++ b/apt-pkg/sourcelist.h
@@ -108,7 +108,7 @@ class pkgSourceList
/** \brief add file for parsing, but not to the cache
*
- * pkgIndexFiles origining from pkgSourcesList are included in
+ * pkgIndexFiles originating from pkgSourcesList are included in
* srcpkgcache, the status files added via #AddStatusFiles are
* included in pkgcache, but these files here are not included in
* any cache to have the possibility of having a file included just