Bläddra i källkod

Retry support
Author: jgg
Date: 1999-01-30 08:08:54 GMT
Retry support

Arch Librarian 22 år sedan
förälder
incheckning
7d8afa391c
6 ändrade filer med 40 tillägg och 17 borttagningar
  1. 22 6
      apt-pkg/acquire-item.cc
  2. 5 4
      apt-pkg/acquire-item.h
  3. 4 4
      apt-pkg/acquire-worker.cc
  4. 2 2
      apt-pkg/acquire.cc
  5. 4 0
      doc/apt.conf.5.yo
  6. 3 1
      doc/examples/apt.conf

+ 22 - 6
apt-pkg/acquire-item.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire-item.cc,v 1.19 1999/01/27 02:48:52 jgg Exp $
+// $Id: acquire-item.cc,v 1.20 1999/01/30 08:08:54 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Item - Item to acquire
    Acquire Item - Item to acquire
@@ -51,16 +51,17 @@ pkgAcquire::Item::~Item()
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* We return to an idle state if there are still other queues that could
 /* We return to an idle state if there are still other queues that could
    fetch this object */
    fetch this object */
-void pkgAcquire::Item::Failed(string Message)
+void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 {
 {
    Status = StatIdle;
    Status = StatIdle;
    ErrorText = LookupTag(Message,"Message");
    ErrorText = LookupTag(Message,"Message");
    if (QueueCounter <= 1)
    if (QueueCounter <= 1)
    {
    {
       /* This indicates that the file is not available right now but might
       /* This indicates that the file is not available right now but might
-         be sometime later. If we do a retry cycle then this should be 
+         be sometime later. If we do a retry cycle then this should be
 	 retried */
 	 retried */
-      if (StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
+      if (Cnf->LocalOnly == true &&
+	  StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
       {
       {
 	 Status = StatIdle;
 	 Status = StatIdle;
 	 Owner->Dequeue(this);
 	 Owner->Dequeue(this);
@@ -338,6 +339,8 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
                Item(Owner), Version(Version), Sources(Sources), Recs(Recs), 
                Item(Owner), Version(Version), Sources(Sources), Recs(Recs), 
                StoreFilename(StoreFilename), Vf(Version.FileList())
                StoreFilename(StoreFilename), Vf(Version.FileList())
 {
 {
+   Retries = _config->FindI("Acquire::Retries",0);
+      
    // Select a source
    // Select a source
    if (QueueNext() == false && _error->PendingError() == false)
    if (QueueNext() == false && _error->PendingError() == false)
       _error->Error("I wasn't able to locate file for the %s package. "
       _error->Error("I wasn't able to locate file for the %s package. "
@@ -477,10 +480,23 @@ string pkgAcqArchive::Describe()
 // AcqArchive::Failed - Failure handler					/*{{{*/
 // AcqArchive::Failed - Failure handler					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* Here we try other sources */
 /* Here we try other sources */
-void pkgAcqArchive::Failed(string Message)
+void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 {
 {
    ErrorText = LookupTag(Message,"Message");
    ErrorText = LookupTag(Message,"Message");
    if (QueueNext() == false)
    if (QueueNext() == false)
-      Item::Failed(Message);
+   {
+      // This is the retry counter
+      if (Retries != 0 &&
+	  Cnf->LocalOnly == false &&
+	  StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
+      {
+	 Retries--;
+	 Vf = Version.FileList();
+	 if (QueueNext() == true)
+	    return;
+      }
+      
+      Item::Failed(Message,Cnf);
+   }
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 5 - 4
apt-pkg/acquire-item.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire-item.h,v 1.13 1999/01/30 06:07:24 jgg Exp $
+// $Id: acquire-item.h,v 1.14 1999/01/30 08:08:54 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Item - Item to acquire
    Acquire Item - Item to acquire
@@ -55,8 +55,8 @@ class pkgAcquire::Item
    
    
    // File to write the fetch into
    // File to write the fetch into
    string DestFile;
    string DestFile;
-   
-   virtual void Failed(string Message);
+
+   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Done(string Message,unsigned long Size,string Md5Hash);
    virtual void Done(string Message,unsigned long Size,string Md5Hash);
    virtual void Start(string Message,unsigned long Size);
    virtual void Start(string Message,unsigned long Size);
    virtual string MD5Sum() {return string();};
    virtual string MD5Sum() {return string();};
@@ -116,12 +116,13 @@ class pkgAcqArchive : public pkgAcquire::Item
    string MD5;
    string MD5;
    string &StoreFilename;
    string &StoreFilename;
    pkgCache::VerFileIterator Vf;
    pkgCache::VerFileIterator Vf;
+   unsigned int Retries;
    
    
    bool QueueNext();
    bool QueueNext();
    
    
    public:
    public:
    
    
-   virtual void Failed(string Message);
+   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual string MD5Sum() {return MD5;};
    virtual string MD5Sum() {return MD5;};
    virtual void Done(string Message,unsigned long Size,string Md5Hash);
    virtual void Done(string Message,unsigned long Size,string Md5Hash);
    virtual string Describe();
    virtual string Describe();

+ 4 - 4
apt-pkg/acquire-worker.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire-worker.cc,v 1.18 1999/01/27 02:48:52 jgg Exp $
+// $Id: acquire-worker.cc,v 1.19 1999/01/30 08:08:54 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Worker 
    Acquire Worker 
@@ -281,12 +281,12 @@ bool pkgAcquire::Worker::RunMessages()
 	    pkgAcquire::Item *Owner = Itm->Owner;
 	    pkgAcquire::Item *Owner = Itm->Owner;
 	    pkgAcquire::ItemDesc Desc = *Itm;
 	    pkgAcquire::ItemDesc Desc = *Itm;
 	    OwnerQ->ItemDone(Itm);
 	    OwnerQ->ItemDone(Itm);
-	    Owner->Failed(Message);
+	    Owner->Failed(Message,Config);
 	    ItemDone();
 	    ItemDone();
-	    
+
 	    if (Log != 0)
 	    if (Log != 0)
 	       Log->Fail(Desc);
 	       Log->Fail(Desc);
-	    
+
 	    break;
 	    break;
 	 }	 
 	 }	 
 	 
 	 

+ 2 - 2
apt-pkg/acquire.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire.cc,v 1.25 1999/01/30 06:07:24 jgg Exp $
+// $Id: acquire.cc,v 1.26 1999/01/30 08:08:54 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire - File Acquiration
    Acquire - File Acquiration
@@ -563,7 +563,7 @@ bool pkgAcquire::Queue::Shutdown()
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
-// Queue::Finditem - Find a URI in the item list			/*{{{*/
+// Queue::FindItem - Find a URI in the item list			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
 pkgAcquire::Queue::QItem *pkgAcquire::Queue::FindItem(string URI,pkgAcquire::Worker *Owner)
 pkgAcquire::Queue::QItem *pkgAcquire::Queue::FindItem(string URI,pkgAcquire::Worker *Owner)

+ 4 - 0
doc/apt.conf.5.yo

@@ -72,6 +72,10 @@ determins how APT parallelizes outgoing connections. bf(host) means that
 one connection per target host will be opened, bf(access) means that one
 one connection per target host will be opened, bf(access) means that one
 connection per URI type will be opened.
 connection per URI type will be opened.
 
 
+dit(bf(Retries))
+Number of retries to perform. If this is non-zero apt will retry failed 
+files the given number of times.
+
 dit(bf(http))
 dit(bf(http))
 HTTP URIs; http::Proxy is the default http proxy to use. It is in the standard
 HTTP URIs; http::Proxy is the default http proxy to use. It is in the standard
 form of em(http://[[user][:pass]@]host[:port]/). Per host proxies can also
 form of em(http://[[user][:pass]@]host[:port]/). Per host proxies can also

+ 3 - 1
doc/examples/apt.conf

@@ -1,4 +1,4 @@
-// $Id: apt.conf,v 1.19 1998/12/14 04:00:34 jgg Exp $
+// $Id: apt.conf,v 1.20 1999/01/30 08:08:54 jgg Exp $
 /* This file is an index of all APT configuration directives. It should
 /* This file is an index of all APT configuration directives. It should
    NOT actually be used as a real config file, though it is a completely
    NOT actually be used as a real config file, though it is a completely
    valid file.
    valid file.
@@ -29,6 +29,7 @@ APT {
      Fix-Missing "false";     
      Fix-Missing "false";     
      Show-Upgraded "false";
      Show-Upgraded "false";
      No-Upgrade "false";
      No-Upgrade "false";
+     Print-URIs "false";
   };
   };
 
 
   Cache {
   Cache {
@@ -50,6 +51,7 @@ APT {
 Acquire
 Acquire
 {
 {
   Queue-Mode "host";       // host|access
   Queue-Mode "host";       // host|access
+  Retry "false";
   
   
   // HTTP method configuration
   // HTTP method configuration
   http 
   http