X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/aa0e1101d75e6b61d63dc486caa0ab32a45b024f..c98b1307f0e9c1712b8e36b825724966d9d40eec:/apt-pkg/acquire.cc diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index e197037db..842f2e31a 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire.cc,v 1.35 1999/06/06 06:58:36 jgg Exp $ +// $Id: acquire.cc,v 1.38 1999/07/30 05:36:52 jgg Exp $ /* ###################################################################### Acquire - File Acquiration @@ -53,15 +53,23 @@ pkgAcquire::pkgAcquire(pkgAcquireStatus *Log) : Log(Log) /* Free our memory, clean up the queues (destroy the workers) */ pkgAcquire::~pkgAcquire() { - while (Items.size() != 0) - delete Items[0]; - while (Configs != 0) { MethodConfig *Jnk = Configs; Configs = Configs->Next; delete Jnk; } + + Shutdown(); +} + /*}}}*/ +// pkgAcquire::Shutdown - Clean out the acquire object /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void pkgAcquire::Shutdown() +{ + while (Items.size() != 0) + delete Items[0]; while (Queues != 0) { @@ -125,7 +133,7 @@ void pkgAcquire::Remove(Worker *Work) // Acquire::Enqueue - Queue an URI for fetching /*{{{*/ // --------------------------------------------------------------------- /* This is the entry point for an item. An item calls this function when - it is construction which creates a queue (based on the current queue + it is constructed which creates a queue (based on the current queue mode) and puts the item in that queue. If the system is running then the queue might be started. */ void pkgAcquire::Enqueue(ItemDesc &Item) @@ -275,7 +283,7 @@ void pkgAcquire::RunFds(fd_set *RSet,fd_set *WSet) /* This runs the queues. It manages a select loop for all of the Worker tasks. The workers interact with the queues and items to manage the actual fetch. */ -bool pkgAcquire::Run() +pkgAcquire::RunResult pkgAcquire::Run() { Running = true; @@ -285,6 +293,8 @@ bool pkgAcquire::Run() if (Log != 0) Log->Start(); + bool WasCancelled = false; + // Run till all things have been acquired struct timeval tv; tv.tv_sec = 0; @@ -321,8 +331,11 @@ bool pkgAcquire::Run() tv.tv_usec = 500000; for (Worker *I = Workers; I != 0; I = I->NextAcquire) I->Pulse(); - if (Log != 0) - Log->Pulse(this); + if (Log != 0 && Log->Pulse(this) == false) + { + WasCancelled = true; + break; + } } } @@ -338,7 +351,11 @@ bool pkgAcquire::Run() for (Item **I = Items.begin(); I != Items.end(); I++) (*I)->Finished(); - return !_error->PendingError(); + if (_error->PendingError()) + return Failed; + if (WasCancelled) + return Cancelled; + return Continue; } /*}}}*/ // Acquire::Bump - Called when an item is dequeued /*{{{*/ @@ -675,7 +692,7 @@ pkgAcquireStatus::pkgAcquireStatus() /* This computes some internal state variables for the derived classes to use. It generates the current downloaded bytes and total bytes to download as well as the current CPS estimate. */ -void pkgAcquireStatus::Pulse(pkgAcquire *Owner) +bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) { TotalBytes = 0; CurrentBytes = 0; @@ -723,6 +740,10 @@ void pkgAcquireStatus::Pulse(pkgAcquire *Owner) TotalBytes = 1; if (Unknown == Count) TotalBytes = Unknown; + + // Wha?! Is not supposed to happen. + if (CurrentBytes > TotalBytes) + CurrentBytes = TotalBytes; // Compute the CPS struct timeval NewTime; @@ -742,6 +763,8 @@ void pkgAcquireStatus::Pulse(pkgAcquire *Owner) ElapsedTime = (unsigned long)Delta; Time = NewTime; } + + return true; } /*}}}*/ // AcquireStatus::Start - Called when the download is started /*{{{*/