summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:54:01 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:54:01 +0000
commit024d1123bf43ec616da66c2481a8ee877e00b8cb (patch)
treec5d8d4061ea4fefd99dcd3674ef7046f35803542 /apt-pkg
parentb826eb9e018b9abccea67bfa08c075a342ebe59b (diff)
Havocs cancel patch
Author: jgg Date: 1999-06-13 05:06:40 GMT Havocs cancel patch
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire.cc23
-rw-r--r--apt-pkg/acquire.h9
2 files changed, 23 insertions, 9 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index e197037db..734f5e7ab 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.36 1999/06/13 05:06:40 jgg Exp $
/* ######################################################################
Acquire - File Acquiration
@@ -275,7 +275,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 +285,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 +323,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 +343,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 +684,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;
@@ -742,6 +751,8 @@ void pkgAcquireStatus::Pulse(pkgAcquire *Owner)
ElapsedTime = (unsigned long)Delta;
Time = NewTime;
}
+
+ return true;
}
/*}}}*/
// AcquireStatus::Start - Called when the download is started /*{{{*/
diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h
index 156fc7aae..6a1583cca 100644
--- a/apt-pkg/acquire.h
+++ b/apt-pkg/acquire.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire.h,v 1.20 1999/03/27 03:02:39 jgg Exp $
+// $Id: acquire.h,v 1.21 1999/06/13 05:06:40 jgg Exp $
/* ######################################################################
Acquire - File Acquiration
@@ -91,7 +91,10 @@ class pkgAcquire
public:
MethodConfig *GetConfig(string Access);
- bool Run();
+
+ enum RunResult {Continue,Failed,Cancelled};
+
+ RunResult Run();
// Simple iteration mechanism
inline Worker *WorkersBegin() {return Workers;};
@@ -259,7 +262,7 @@ class pkgAcquireStatus
virtual void Fetch(pkgAcquire::ItemDesc &Itm) {};
virtual void Done(pkgAcquire::ItemDesc &Itm) {};
virtual void Fail(pkgAcquire::ItemDesc &Itm) {};
- virtual void Pulse(pkgAcquire *Owner);
+ virtual bool Pulse(pkgAcquire *Owner); // returns false on user cancel
virtual void Start();
virtual void Stop();