From 8e5fc8f5bea54e3c016a14fe4025dcb94864e874 Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 16:54:53 +0000 Subject: CDROMs are unmounted Author: jgg Date: 1999-10-18 00:37:35 GMT CDROMs are unmounted --- apt-pkg/acquire-method.cc | 13 +++++--- apt-pkg/acquire-method.h | 7 +++-- apt-pkg/acquire-worker.cc | 8 +++-- apt-pkg/acquire-worker.h | 3 +- apt-pkg/acquire.cc | 77 ++++++++++++++++++++++++++--------------------- apt-pkg/acquire.h | 7 +++-- 6 files changed, 67 insertions(+), 48 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 13b11c8db..5b7251a5f 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-method.cc,v 1.20 1999/08/04 02:39:13 jgg Exp $ +// $Id: acquire-method.cc,v 1.21 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire Method @@ -49,6 +49,9 @@ pkgAcqMethod::pkgAcqMethod(const char *Ver,unsigned long Flags) if ((Flags & LocalOnly) == LocalOnly) strcat(End,"Local-Only: true\n"); + + if ((Flags & NeedsCleanup) == NeedsCleanup) + strcat(End,"Needs-Cleanup: true\n"); strcat(End,"\n"); if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S)) @@ -309,10 +312,9 @@ int pkgAcqMethod::Run(bool Single) { if (Single == false) if (WaitFd(STDIN_FILENO) == false) - return 0; - + break; if (ReadMessages(STDIN_FILENO,Messages) == false) - return 0; + break; } // Single mode exits if the message queue is empty @@ -332,7 +334,7 @@ int pkgAcqMethod::Run(bool Single) } switch (Number) - { + { case 601: if (Configuration(Message) == false) return 100; @@ -365,6 +367,7 @@ int pkgAcqMethod::Run(bool Single) } } + Exit(); return 0; } /*}}}*/ diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 225ec15a8..ca03dd1d1 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-method.h,v 1.11 1999/07/20 05:53:33 jgg Exp $ +// $Id: acquire-method.h,v 1.12 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire Method - Method helper class + functions @@ -61,12 +61,13 @@ class pkgAcqMethod void URIStart(FetchResult &Res); void URIDone(FetchResult &Res,FetchResult *Alt = 0); bool MediaFail(string Required,string Drive); - + void Exit() {}; + public: enum CnfFlags {SingleInstance = (1<<0), Pipeline = (1<<1), SendConfig = (1<<2), - LocalOnly = (1<<3)}; + LocalOnly = (1<<3), NeedsCleanup = (1<<4)}; void Log(const char *Format,...); void Status(const char *Format,...); diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 972ab2455..f6b14da3c 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-worker.cc,v 1.27 1999/08/28 01:49:56 jgg Exp $ +// $Id: acquire-worker.cc,v 1.28 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire Worker @@ -86,7 +86,10 @@ pkgAcquire::Worker::~Worker() if (Process > 0) { - kill(Process,SIGINT); + /* Closing of stdin is the signal to exit and die when the process + indicates it needs cleanup */ + if (Config->NeedsCleanup == false) + kill(Process,SIGINT); ExecWait(Process,Access.c_str(),true); } } @@ -323,6 +326,7 @@ bool pkgAcquire::Worker::Capabilities(string Message) Config->Pipeline = StringToBool(LookupTag(Message,"Pipeline"),false); Config->SendConfig = StringToBool(LookupTag(Message,"Send-Config"),false); Config->LocalOnly = StringToBool(LookupTag(Message,"Local-Only"),false); + Config->NeedsCleanup = StringToBool(LookupTag(Message,"Needs-Cleanup"),false); // Some debug text if (Debug == true) diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h index 4c3a666ae..797ea3f7c 100644 --- a/apt-pkg/acquire-worker.h +++ b/apt-pkg/acquire-worker.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-worker.h,v 1.10 1999/05/23 06:47:43 jgg Exp $ +// $Id: acquire-worker.h,v 1.11 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire Worker - Worker process manager @@ -79,6 +79,7 @@ class pkgAcquire::Worker bool QueueItem(pkgAcquire::Queue::QItem *Item); bool Start(); void Pulse(); + inline const MethodConfig *GetConf() const {return Config;}; Worker(Queue *OwnerQ,MethodConfig *Config,pkgAcquireStatus *Log); Worker(MethodConfig *Config); diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 99dacf5be..7a93fbd8e 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.39 1999/10/16 19:53:18 jgg Exp $ +// $Id: acquire.cc,v 1.40 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire - File Acquiration @@ -63,7 +63,7 @@ pkgAcquire::~pkgAcquire() Shutdown(); } /*}}}*/ -// pkgAcquire::Shutdown - Clean out the acquire object /*{{{*/ +// Acquire::Shutdown - Clean out the acquire object /*{{{*/ // --------------------------------------------------------------------- /* */ void pkgAcquire::Shutdown() @@ -345,11 +345,11 @@ pkgAcquire::RunResult pkgAcquire::Run() // Shut down the acquire bits Running = false; for (Queue *I = Queues; I != 0; I = I->Next) - I->Shutdown(); + I->Shutdown(false); // Shut down the items for (Item **I = Items.begin(); I != Items.end(); I++) - (*I)->Finished(); + (*I)->Finished(); if (_error->PendingError()) return Failed; @@ -453,7 +453,7 @@ unsigned long pkgAcquire::PartialPresent() return Total; } /*}}}*/ -// pkgAcquire::UriBegin - Start iterator for the uri list /*{{{*/ +// Acquire::UriBegin - Start iterator for the uri list /*{{{*/ // --------------------------------------------------------------------- /* */ pkgAcquire::UriIterator pkgAcquire::UriBegin() @@ -461,7 +461,7 @@ pkgAcquire::UriIterator pkgAcquire::UriBegin() return UriIterator(Queues); } /*}}}*/ -// pkgAcquire::UriEnd - End iterator for the uri list /*{{{*/ +// Acquire::UriEnd - End iterator for the uri list /*{{{*/ // --------------------------------------------------------------------- /* */ pkgAcquire::UriIterator pkgAcquire::UriEnd() @@ -501,7 +501,7 @@ pkgAcquire::Queue::Queue(string Name,pkgAcquire *Owner) : Name(Name), /* */ pkgAcquire::Queue::~Queue() { - Shutdown(); + Shutdown(true); while (Items != 0) { @@ -560,44 +560,53 @@ bool pkgAcquire::Queue::Dequeue(Item *Owner) /*}}}*/ // Queue::Startup - Start the worker processes /*{{{*/ // --------------------------------------------------------------------- -/* */ +/* It is possible for this to be called with a pre-existing set of + workers. */ bool pkgAcquire::Queue::Startup() { - Shutdown(); - - URI U(Name); - pkgAcquire::MethodConfig *Cnf = Owner->GetConfig(U.Access); - if (Cnf == 0) - return false; - - Workers = new Worker(this,Cnf,Owner->Log); - Owner->Add(Workers); - if (Workers->Start() == false) - return false; - - /* When pipelining we commit 10 items. This needs to change when we - added other source retry to have cycle maintain a pipeline depth - on its own. */ - if (Cnf->Pipeline == true) - MaxPipeDepth = 10; - else - MaxPipeDepth = 1; + if (Workers == 0) + { + URI U(Name); + pkgAcquire::MethodConfig *Cnf = Owner->GetConfig(U.Access); + if (Cnf == 0) + return false; + + Workers = new Worker(this,Cnf,Owner->Log); + Owner->Add(Workers); + if (Workers->Start() == false) + return false; + + /* When pipelining we commit 10 items. This needs to change when we + added other source retry to have cycle maintain a pipeline depth + on its own. */ + if (Cnf->Pipeline == true) + MaxPipeDepth = 10; + else + MaxPipeDepth = 1; + } return Cycle(); } /*}}}*/ // Queue::Shutdown - Shutdown the worker processes /*{{{*/ // --------------------------------------------------------------------- -/* */ -bool pkgAcquire::Queue::Shutdown() +/* If final is true then all workers are eliminated, otherwise only workers + that do not need cleanup are removed */ +bool pkgAcquire::Queue::Shutdown(bool Final) { // Delete all of the workers - while (Workers != 0) + pkgAcquire::Worker **Cur = &Workers; + while (*Cur != 0) { - pkgAcquire::Worker *Jnk = Workers; - Workers = Workers->NextQueue; - Owner->Remove(Jnk); - delete Jnk; + pkgAcquire::Worker *Jnk = *Cur; + if (Final == true || Jnk->GetConf()->NeedsCleanup == false) + { + *Cur = Jnk->NextQueue; + Owner->Remove(Jnk); + delete Jnk; + } + else + Cur = &(*Cur)->NextQueue; } return true; diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 0d12b554f..e05ab3adc 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.24 1999/07/20 05:53:33 jgg Exp $ +// $Id: acquire.h,v 1.25 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire - File Acquiration @@ -175,7 +175,7 @@ class pkgAcquire::Queue bool ItemDone(QItem *Itm); bool Startup(); - bool Shutdown(); + bool Shutdown(bool Final); bool Cycle(); void Bump(); @@ -229,7 +229,8 @@ struct pkgAcquire::MethodConfig bool Pipeline; bool SendConfig; bool LocalOnly; - + bool NeedsCleanup; + MethodConfig(); }; -- cgit v1.2.3