From dcaa1185506986142bccd990a5dca4c6ec1228cf Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 4 Mar 2012 23:47:05 +0100 Subject: fix a bunch of cppcheck "(warning) Member variable '<#>' is not initialized in the constructor." messages (no functional change) --- apt-pkg/acquire.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/acquire.cc') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index cdc3fba4b..573a85c2f 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -766,7 +766,7 @@ void pkgAcquire::Queue::Bump() // AcquireStatus::pkgAcquireStatus - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgAcquireStatus::pkgAcquireStatus() : Update(true), MorePulses(false) +pkgAcquireStatus::pkgAcquireStatus() : d(NULL), Update(true), MorePulses(false) { Start(); } -- cgit v1.2.3 From 31bda5000136d77f516cf2080257835fb44deaef Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 20 Mar 2012 17:05:11 +0100 Subject: * apt-pkg/acquire-worker.cc: - check return of write() as gcc recommends * apt-pkg/acquire.cc: - check return of write() as gcc recommends * apt-pkg/cdrom.cc: - check return of chdir() and link() as gcc recommends * apt-pkg/clean.cc: - check return of chdir() as gcc recommends * apt-pkg/contrib/netrc.cc: - check return of asprintf() as gcc recommends --- apt-pkg/acquire.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'apt-pkg/acquire.cc') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 573a85c2f..19bcca8a1 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -872,7 +872,23 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) << ":" << (CurrentBytes/float(TotalBytes)*100.0) << ":" << msg << endl; - write(fd, status.str().c_str(), status.str().size()); + + std::string const dlstatus = status.str(); + size_t done = 0; + size_t todo = dlstatus.size(); + errno = 0; + int res = 0; + do + { + res = write(fd, dlstatus.c_str() + done, todo); + if (res < 0 && errno == EINTR) + continue; + if (res < 0) + break; + done += res; + todo -= res; + } + while (res > 0 && todo > 0); } return true; -- cgit v1.2.3 From d68d65ad637526e46ea77ab83e07470d26df15fc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 11 Apr 2012 13:25:28 +0200 Subject: use a static FileFd::Write overload to reduce duplication of write()-retry code --- apt-pkg/acquire.cc | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'apt-pkg/acquire.cc') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 19bcca8a1..5e1419056 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -874,21 +874,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) << endl; std::string const dlstatus = status.str(); - size_t done = 0; - size_t todo = dlstatus.size(); - errno = 0; - int res = 0; - do - { - res = write(fd, dlstatus.c_str() + done, todo); - if (res < 0 && errno == EINTR) - continue; - if (res < 0) - break; - done += res; - todo -= res; - } - while (res > 0 && todo > 0); + FileFd::Write(fd, dlstatus.c_str(), dlstatus.size()); } return true; -- cgit v1.2.3 From 5674f6b3163d73260e25ce7d350aaac50071eb0e Mon Sep 17 00:00:00 2001 From: Raphael Geissert Date: Mon, 14 May 2012 18:07:01 +0200 Subject: * apt-pkg/acquire*.cc: - handle redirections in the worker with the right method instead of in the method the redirection occured in (Closes: #668111) * methods/http.cc: - forbid redirects to change protocol --- apt-pkg/acquire.cc | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'apt-pkg/acquire.cc') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 5e1419056..a8a5abd34 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -244,11 +244,19 @@ void pkgAcquire::Dequeue(Item *Itm) { Queue *I = Queues; bool Res = false; - for (; I != 0; I = I->Next) - Res |= I->Dequeue(Itm); - if (Debug == true) clog << "Dequeuing " << Itm->DestFile << endl; + + for (; I != 0; I = I->Next) + { + if (I->Dequeue(Itm)) + { + Res = true; + if (Debug == true) + clog << "Dequeued from " << I->Name << endl; + } + } + if (Res == true) ToFetch--; } @@ -269,9 +277,30 @@ 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 AccessSchema = U.Access + ':', + FullQueueName = AccessSchema + U.Host; + unsigned int Instances = 0, SchemaLength = AccessSchema.length(); + + Queue *I = Queues; + for (; I != 0; I = I->Next) { + // if the queue already exists, re-use it + if (I->Name == FullQueueName) + return FullQueueName; + + if (I->Name.compare(0, SchemaLength, AccessSchema) == 0) + Instances++; + } + + if (Debug) { + clog << "Found " << Instances << " instances of " << U.Access << endl; + } + + if (Instances >= (unsigned int)_config->FindI("Acquire::QueueHost::Limit",10)) + return U.Access; - return U.Access + ':' + U.Host; + return FullQueueName; } /*}}}*/ // Acquire::GetConfig - Fetch the configuration information /*{{{*/ -- cgit v1.2.3