]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-worker.cc
be able to disable resolver with APT::Get::CallResolver and disable
[apt.git] / apt-pkg / acquire-worker.cc
index 739c9e32ccacf1e4381e1872b3a3db61c3f3067a..ddd8e31018c5bcc028d4fe0c2183fc558876704d 100644 (file)
@@ -199,6 +199,17 @@ bool pkgAcquire::Worker::RunMessages()
       pkgAcquire::Queue::QItem *Itm = 0;
       if (URI.empty() == false)
         Itm = OwnerQ->FindItem(URI,this);
       pkgAcquire::Queue::QItem *Itm = 0;
       if (URI.empty() == false)
         Itm = OwnerQ->FindItem(URI,this);
+
+      // update used mirror
+      string UsedMirror = LookupTag(Message,"UsedMirror", "");
+      if (!UsedMirror.empty() && 
+          Itm && 
+          Itm->Description.find(" ") != string::npos) 
+      {
+         Itm->Description.replace(0, Itm->Description.find(" "), UsedMirror);
+         // FIXME: will we need this as well?
+         //Itm->ShortDesc = UsedMirror;
+      }
       
       // Determine the message number and dispatch
       switch (Number)
       
       // Determine the message number and dispatch
       switch (Number)
@@ -220,6 +231,20 @@ bool pkgAcquire::Worker::RunMessages()
         Status = LookupTag(Message,"Message");
         break;
            
         Status = LookupTag(Message,"Message");
         break;
            
+         // 103 Redirect
+         case 103:
+         {
+            if (Itm == 0)
+            {
+               _error->Error("Method gave invalid 103 Redirect message");
+               break;
+            }
+            string NewURI = LookupTag(Message,"New-URI",URI.c_str());
+            Itm->URI = NewURI;
+            break;
+         }
+   
         // 200 URI Start
         case 200:
         {
         // 200 URI Start
         case 200:
         {
@@ -325,6 +350,7 @@ bool pkgAcquire::Worker::RunMessages()
            // set some status
            if(LookupTag(Message,"FailReason") == "Timeout" || 
               LookupTag(Message,"FailReason") == "TmpResolveFailure" ||
            // set some status
            if(LookupTag(Message,"FailReason") == "Timeout" || 
               LookupTag(Message,"FailReason") == "TmpResolveFailure" ||
+              LookupTag(Message,"FailReason") == "ResolveFailure" ||
               LookupTag(Message,"FailReason") == "ConnectionRefused") 
               Owner->Status = pkgAcquire::Item::StatTransientNetworkError;
 
               LookupTag(Message,"FailReason") == "ConnectionRefused") 
               Owner->Status = pkgAcquire::Item::StatTransientNetworkError;
 
@@ -512,10 +538,6 @@ bool pkgAcquire::Worker::OutFdReady()
    
    if (Res <= 0)
       return MethodFailure();
    
    if (Res <= 0)
       return MethodFailure();
-
-   // Hmm.. this should never happen.
-   if (Res < 0)
-      return true;
    
    OutQueue.erase(0,Res);
    if (OutQueue.empty() == true)
    
    OutQueue.erase(0,Res);
    if (OutQueue.empty() == true)
@@ -543,7 +565,8 @@ bool pkgAcquire::Worker::MethodFailure()
 {
    _error->Error("Method %s has died unexpectedly!",Access.c_str());
    
 {
    _error->Error("Method %s has died unexpectedly!",Access.c_str());
    
-   ExecWait(Process,Access.c_str(),true);
+   // do not reap the child here to show meaningfull error to the user
+   ExecWait(Process,Access.c_str(),false);
    Process = -1;
    close(InFd);
    close(OutFd);
    Process = -1;
    close(InFd);
    close(OutFd);