X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/7d8afa391c5cd04e797a2b41fe3b946631254995..421c8d109932a2615b9327c8b69aad715d4b1162:/apt-pkg/acquire-worker.cc diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 099a43e2e..972ab2455 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.19 1999/01/30 08:08:54 jgg Exp $ +// $Id: acquire-worker.cc,v 1.27 1999/08/28 01:49:56 jgg Exp $ /* ###################################################################### Acquire Worker @@ -24,9 +24,10 @@ #include #include +#include #include -#include #include +#include /*}}}*/ // Worker::Worker - Constructor for Queue startup /*{{{*/ @@ -39,7 +40,9 @@ pkgAcquire::Worker::Worker(Queue *Q,MethodConfig *Cnf, Config = Cnf; Access = Cnf->Access; CurrentItem = 0; - + TotalSize = 0; + CurrentSize = 0; + Construct(); } /*}}}*/ @@ -52,6 +55,8 @@ pkgAcquire::Worker::Worker(MethodConfig *Cnf) Config = Cnf; Access = Cnf->Access; CurrentItem = 0; + TotalSize = 0; + CurrentSize = 0; Construct(); } @@ -82,8 +87,7 @@ pkgAcquire::Worker::~Worker() if (Process > 0) { kill(Process,SIGINT); - if (waitpid(Process,0,0) != Process) - _error->Warning("I waited but nothing was there!"); + ExecWait(Process,Access.c_str(),true); } } /*}}}*/ @@ -113,12 +117,7 @@ bool pkgAcquire::Worker::Start() SetCloseExec(Pipes[0],true); // Fork off the process - Process = fork(); - if (Process < 0) - { - cerr << "FATAL -> Failed to fork." << endl; - exit(100); - } + Process = ExecFork(); // Spawn the subprocess if (Process == 0) @@ -228,8 +227,9 @@ bool pkgAcquire::Worker::RunMessages() CurrentItem = Itm; CurrentSize = 0; TotalSize = atoi(LookupTag(Message,"Size","0").c_str()); + ResumePoint = atoi(LookupTag(Message,"Resume-Point","0").c_str()); Itm->Owner->Start(Message,atoi(LookupTag(Message,"Size","0").c_str())); - + if (Log != 0) Log->Fetch(*Itm); @@ -248,8 +248,13 @@ bool pkgAcquire::Worker::RunMessages() pkgAcquire::Item *Owner = Itm->Owner; pkgAcquire::ItemDesc Desc = *Itm; OwnerQ->ItemDone(Itm); + if (TotalSize != 0 && + (unsigned)atoi(LookupTag(Message,"Size","0").c_str()) != TotalSize) + _error->Warning("Bizzar Error - File size is not what the server reported %s %u", + LookupTag(Message,"Size","0").c_str(),TotalSize); + Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()), - LookupTag(Message,"MD5-Hash")); + LookupTag(Message,"MD5-Hash")); ItemDone(); // Log that we are done @@ -265,7 +270,7 @@ bool pkgAcquire::Worker::RunMessages() } else Log->Done(Desc); - } + } break; } @@ -433,7 +438,13 @@ bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item) /* */ bool pkgAcquire::Worker::OutFdReady() { - int Res = write(OutFd,OutQueue.begin(),OutQueue.length()); + int Res; + do + { + Res = write(OutFd,OutQueue.begin(),OutQueue.length()); + } + while (Res < 0 && errno == EINTR); + if (Res <= 0) return MethodFailure(); @@ -467,8 +478,7 @@ bool pkgAcquire::Worker::MethodFailure() { _error->Error("Method %s has died unexpectedly!",Access.c_str()); - if (waitpid(Process,0,0) != Process) - _error->Warning("I waited but nothing was there!"); + ExecWait(Process,Access.c_str(),true); Process = -1; close(InFd); close(OutFd); @@ -494,6 +504,10 @@ void pkgAcquire::Worker::Pulse() if (stat(CurrentItem->Owner->DestFile.c_str(),&Buf) != 0) return; CurrentSize = Buf.st_size; + + // Hmm? Should not happen... + if (CurrentSize > TotalSize && TotalSize != 0) + TotalSize = CurrentSize; } /*}}}*/ // Worker::ItemDone - Called when the current item is finished /*{{{*/