]> git.saurik.com Git - apt.git/commitdiff
Only enable pipelining if server is HTTP/1.1
authorJulian Andres Klode <jak@debian.org>
Tue, 12 Jan 2016 14:18:12 +0000 (15:18 +0100)
committerJulian Andres Klode <jak@debian.org>
Tue, 12 Jan 2016 22:40:59 +0000 (23:40 +0100)
Just enabling it for anyone breaks with HTTP/1.0 servers and
proxies sometimes.

Closes: #810796
methods/server.cc
methods/server.h
test/integration/test-http-pipeline-messup

index d5188d4a31450a81248b7269b87b4edc24602a58..6340390d48c8f5c4314fb1da0d118e60ca1eccf1 100644 (file)
@@ -150,9 +150,15 @@ bool ServerState::HeaderLine(string Line)
       else
       {
         if (Major == 1 && Minor == 0)
+        {
            Persistent = false;
+        }
         else
+        {
            Persistent = true;
+           if (PipelineAllowed)
+              Pipeline = true;
+        }
       }
 
       return true;
@@ -532,6 +538,7 @@ int ServerMethod::Loop()
            _error->Discard();
            Server->Close();
            Server->Pipeline = false;
+           Server->PipelineAllowed = false;
            
            if (FailCounter >= 2)
            {
@@ -604,6 +611,7 @@ int ServerMethod::Loop()
                           strprintf(out, _("Automatically disabled %s due to incorrect response from server/proxy. (man 5 apt.conf)"), "Acquire::http::PipelineDepth");
                           std::cerr << "W: " << out << std::endl;
                           Server->Pipeline = false;
+                          Server->PipelineAllowed = false;
                           // we keep the PipelineDepth value so that the rest of the queue can be fixed up as well
                        }
                        Rename(Res.Filename, I->DestFile);
index 365bc0879ff549b6f19e71fc9c9ef48d1e313a62..3f6502432e5b11789913948cd37d93d8a3ccc32c 100644 (file)
@@ -51,6 +51,7 @@ struct ServerState
    enum {Chunked,Stream,Closes} Encoding;
    enum {Header, Data} State;
    bool Persistent;
+   bool PipelineAllowed;
    std::string Location;
 
    // This is a Persistent attribute of the server itself.
@@ -86,7 +87,7 @@ struct ServerState
    bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
    virtual void Reset() {Major = 0; Minor = 0; Result = 0; Code[0] = '\0'; TotalFileSize = 0; JunkSize = 0;
                 StartPos = 0; Encoding = Closes; time(&Date); HaveContent = false;
-                State = Header; Persistent = false; Pipeline = true; MaximumSize = 0;};
+                State = Header; Persistent = false; Pipeline = false; MaximumSize = 0; PipelineAllowed = true;};
    virtual bool WriteResponse(std::string const &Data) = 0;
 
    /** \brief Transfer the data from the socket */
index 4069beb0d88f50cfc48e44411c44e7092e5a56b6..95e890baf49005a3df2211fd9d661208ea63463c 100755 (executable)
@@ -8,6 +8,7 @@ setupenvironment
 configarchitecture "i386"
 
 # try a little harder to create a size mismatch
+buildsimplenativepackage 'pkg0' 'all' '1.0' 'stable' "Depends: foo" '' '' '' '' 'none'
 buildsimplenativepackage 'pkga' 'all' '1.0' 'stable' "Depends: foo" '' '' '' '' 'none'
 buildsimplenativepackage 'pkgb' 'all' '1.0' 'stable' "Depends: foo" '' '' '' '' 'none'
 buildsimplenativepackage 'pkgc' 'all' '1.0' 'stable' "Depends: f$(for i in $(seq 0 1000); do printf 'o'; done)" '' '' '' '' 'none'
@@ -43,8 +44,8 @@ done
 echo 'Acquire::http::Pipeline-Depth 10;' > ../rootdir/etc/apt/apt.conf.d/99enable-pipeline
 
 # the output is a bit strange: it looks like it has downloaded pkga 4 times
-testwarning aptget download pkga pkgb pkgc pkgd
-for pkg in 'pkga' 'pkgb' 'pkgc' 'pkgd'; do
+testwarning aptget download pkg0 pkga pkgb pkgc pkgd
+for pkg in 'pkg0' 'pkga' 'pkgb' 'pkgc' 'pkgd'; do
        testsuccess test -f ${pkg}_1.0_all.deb
        testsuccess cmp ../incoming/${pkg}_1.0_all.deb ${pkg}_1.0_all.deb
        rm -f ${pkg}_1.0_all.deb