X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/a72ace2091afd833e9359514644676c6bca55d96..7f25bdff3a0fa55ba897964d5c82475b45f3325a:/apt-pkg/acquire-worker.cc diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 3e76b3d9d..06a4460d1 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.13 1998/11/29 01:24:18 jgg Exp $ +// $Id: acquire-worker.cc,v 1.16 1998/12/14 06:54:41 jgg Exp $ /* ###################################################################### Acquire Worker @@ -26,6 +26,7 @@ #include #include #include +#include /*}}}*/ // Worker::Worker - Constructor for Queue startup /*{{{*/ @@ -135,7 +136,7 @@ bool pkgAcquire::Worker::Start() Args[1] = 0; execv(Args[0],(char **)Args); cerr << "Failed to exec method " << Args[0] << endl; - exit(100); + _exit(100); } // Fix up our FDs @@ -288,6 +289,11 @@ bool pkgAcquire::Worker::RunMessages() case 401: _error->Error("Method %s General failure: %s",LookupTag(Message,"Message").c_str()); break; + + // 403 Media Change + case 403: + MediaChange(Message); + break; } } return true; @@ -318,6 +324,32 @@ bool pkgAcquire::Worker::Capabilities(string Message) Config->SendConfig << endl; } + return true; +} + /*}}}*/ +// Worker::MediaChange - Request a media change /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool pkgAcquire::Worker::MediaChange(string Message) +{ + if (Log == 0 || Log->MediaChange(LookupTag(Message,"Media"), + LookupTag(Message,"Drive")) == false) + { + char S[300]; + sprintf(S,"603 Media Changed\nFailed: true\n\n"); + if (Debug == true) + clog << " -> " << Access << ':' << QuoteString(S,"\n") << endl; + OutQueue += S; + OutReady = true; + return true; + } + + char S[300]; + sprintf(S,"603 Media Changed\n\n"); + if (Debug == true) + clog << " -> " << Access << ':' << QuoteString(S,"\n") << endl; + OutQueue += S; + OutReady = true; return true; } /*}}}*/ @@ -428,7 +460,8 @@ bool pkgAcquire::Worker::InFdReady() read returned -1. */ bool pkgAcquire::Worker::MethodFailure() { - cerr << "Method " << Access << " has died unexpectedly!" << endl; + _error->Error("Method %s has died unexpectedly!",Access.c_str()); + if (waitpid(Process,0,0) != Process) _error->Warning("I waited but nothing was there!"); Process = -1; @@ -451,8 +484,7 @@ void pkgAcquire::Worker::Pulse() { if (CurrentItem == 0) return; - - + struct stat Buf; if (stat(CurrentItem->Owner->DestFile.c_str(),&Buf) != 0) return;