]> git.saurik.com Git - apt.git/blobdiff - methods/server.cc
test if TMPDIR is accessible before using
[apt.git] / methods / server.cc
index ff67eb09b0dfebaa510a79cfa7e74d9373da2a49..c4689ff122ffb5f2c051e37dee0d48dcdf7415d4 100644 (file)
@@ -324,10 +324,10 @@ ServerMethod::DealWithHeaders(FetchResult &Res)
       failure */
    if (Server->Result < 200 || Server->Result >= 300)
    {
-      char err[255];
-      snprintf(err,sizeof(err)-1,"HttpError%i",Server->Result);
+      std::string err;
+      strprintf(err, "HttpError%u", Server->Result);
       SetFailReason(err);
-      _error->Error("%u %s",Server->Result,Server->Code);
+      _error->Error("%u %s", Server->Result, Server->Code);
       if (Server->HaveContent == true)
         return ERROR_WITH_CONTENT_PAGE;
       return ERROR_UNRECOVERABLE;
@@ -532,6 +532,13 @@ int ServerMethod::Loop()
 
            // Run the data
            bool Result = true;
+
+            // ensure we don't fetch too much
+            // we could do "Server->MaximumSize = Queue->MaximumSize" here
+            // but that would break the clever pipeline messup detection
+            // so instead we use the size of the biggest item in the queue
+            Server->MaximumSize = FindMaximumObjectSizeInQueue();
+
             if (Server->HaveContent)
               Result = Server->RunData(File);
 
@@ -605,7 +612,10 @@ int ServerMethod::Loop()
                  QueueBack = Queue;
               }
               else
+               {
+                  Server->Close();
                  Fail(true);
+               }
            }
            break;
         }
@@ -698,5 +708,15 @@ int ServerMethod::Loop()
    }
    
    return 0;
+}
+                                                                       /*}}}*/
+                                                                       /*{{{*/
+unsigned long long
+ServerMethod::FindMaximumObjectSizeInQueue() const 
+{
+   unsigned long long MaxSizeInQueue = 0;
+   for (FetchItem *I = Queue; I != 0 && I != QueueBack; I = I->Next)
+      MaxSizeInQueue = std::max(MaxSizeInQueue, I->MaximumSize);
+   return MaxSizeInQueue;
 }
                                                                        /*}}}*/