From bce0e0ff327341da3ad54d7ea2bb6d82b3f96879 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 17 Apr 2012 23:47:35 +0200 Subject: newer gcc versions seems to have no problem with that, but while working with g++-4.1 it complains about this so lets be extra clear --- methods/http.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index c62ca71d3..b450b6ffc 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -602,7 +602,7 @@ bool ServerState::HeaderLine(string Line) return true; Size = strtoull(Val.c_str(), NULL, 10); - if (Size == ULLONG_MAX) + if (Size >= std::numeric_limits::max()) return _error->Errno("HeaderLine", _("The HTTP server sent an invalid Content-Length header")); return true; } -- cgit v1.2.3-70-g09d2 From 4ac4a98e16e1ecd34928f6d93389b7106c93c65e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 10 May 2012 00:15:52 +0200 Subject: we don't need zlib (anymore) in rred so don't include it --- methods/rred.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'methods') diff --git a/methods/rred.cc b/methods/rred.cc index 78d1595d4..7c65f8f92 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -15,7 +15,6 @@ #include #include #include -#include #include /*}}}*/ /** \brief RredMethod - ed-style incremential patch method {{{ -- cgit v1.2.3-70-g09d2 From 5674f6b3163d73260e25ce7d350aaac50071eb0e Mon Sep 17 00:00:00 2001 From: Raphael Geissert Date: Mon, 14 May 2012 18:07:01 +0200 Subject: * apt-pkg/acquire*.cc: - handle redirections in the worker with the right method instead of in the method the redirection occured in (Closes: #668111) * methods/http.cc: - forbid redirects to change protocol --- apt-pkg/acquire-method.cc | 18 +++--------------- apt-pkg/acquire-worker.cc | 15 +++++++++++++++ apt-pkg/acquire.cc | 39 ++++++++++++++++++++++++++++++++++----- debian/changelog | 7 +++++++ methods/http.cc | 5 ++++- 5 files changed, 63 insertions(+), 21 deletions(-) (limited to 'methods') diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index e6e02bbc5..5bc1c159a 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -412,26 +412,14 @@ void pkgAcqMethod::Status(const char *Format,...) /*}}}*/ // AcqMethod::Redirect - Send a redirect message /*{{{*/ // --------------------------------------------------------------------- -/* This method sends the redirect message and also manipulates the queue - to keep the pipeline synchronized. */ +/* This method sends the redirect message and dequeues the item as + * the worker will enqueue again later on to the right queue */ void pkgAcqMethod::Redirect(const string &NewURI) { std::cout << "103 Redirect\nURI: " << Queue->Uri << "\n" << "New-URI: " << NewURI << "\n" << "\n" << std::flush; - - // Change the URI for the request. - Queue->Uri = NewURI; - - /* To keep the pipeline synchronized, move the current request to - the end of the queue, past the end of the current pipeline. */ - FetchItem *I; - for (I = Queue; I->Next != 0; I = I->Next) ; - I->Next = Queue; - Queue = Queue->Next; - I->Next->Next = 0; - if (QueueBack == 0) - QueueBack = I->Next; + Dequeue(); } /*}}}*/ // AcqMethod::FetchResult::FetchResult - Constructor /*{{{*/ diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index d6db8bc02..9d90b08bc 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -244,6 +244,21 @@ bool pkgAcquire::Worker::RunMessages() string NewURI = LookupTag(Message,"New-URI",URI.c_str()); Itm->URI = NewURI; + + ItemDone(); + + pkgAcquire::Item *Owner = Itm->Owner; + pkgAcquire::ItemDesc Desc = *Itm; + + // Change the status so that it can be dequeued + Owner->Status = pkgAcquire::Item::StatIdle; + // Mark the item as done (taking care of all queues) + // and then put it in the main queue again + OwnerQ->ItemDone(Itm); + OwnerQ->Owner->Enqueue(Desc); + + if (Log != 0) + Log->Done(Desc); break; } diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 5e1419056..a8a5abd34 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -244,11 +244,19 @@ void pkgAcquire::Dequeue(Item *Itm) { Queue *I = Queues; bool Res = false; - for (; I != 0; I = I->Next) - Res |= I->Dequeue(Itm); - if (Debug == true) clog << "Dequeuing " << Itm->DestFile << endl; + + for (; I != 0; I = I->Next) + { + if (I->Dequeue(Itm)) + { + Res = true; + if (Debug == true) + clog << "Dequeued from " << I->Name << endl; + } + } + if (Res == true) ToFetch--; } @@ -269,9 +277,30 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) /* Single-Instance methods get exactly one queue per URI. This is also used for the Access queue method */ if (Config->SingleInstance == true || QueueMode == QueueAccess) - return U.Access; + return U.Access; + + string AccessSchema = U.Access + ':', + FullQueueName = AccessSchema + U.Host; + unsigned int Instances = 0, SchemaLength = AccessSchema.length(); + + Queue *I = Queues; + for (; I != 0; I = I->Next) { + // if the queue already exists, re-use it + if (I->Name == FullQueueName) + return FullQueueName; + + if (I->Name.compare(0, SchemaLength, AccessSchema) == 0) + Instances++; + } + + if (Debug) { + clog << "Found " << Instances << " instances of " << U.Access << endl; + } + + if (Instances >= (unsigned int)_config->FindI("Acquire::QueueHost::Limit",10)) + return U.Access; - return U.Access + ':' + U.Host; + return FullQueueName; } /*}}}*/ // Acquire::GetConfig - Fetch the configuration information /*{{{*/ diff --git a/debian/changelog b/debian/changelog index 7097a6e99..937bde918 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,13 @@ apt (0.9.4) UNRELEASED; urgency=low * apt-pkg/acquire-methods.cc: - factor out into private Dequeue() to fix access to deleted pointer + [ Raphael Geissert ] + * apt-pkg/acquire*.cc: + - handle redirections in the worker with the right method instead of + in the method the redirection occured in (Closes: #668111) + * methods/http.cc: + - forbid redirects to change protocol + -- David Kalnischkies Fri, 11 May 2012 23:26:59 +0200 apt (0.9.3) unstable; urgency=low diff --git a/methods/http.cc b/methods/http.cc index b450b6ffc..bb02176e9 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -985,7 +985,10 @@ HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv) else { NextURI = DeQuoteString(Srv->Location); - return TRY_AGAIN_OR_REDIRECT; + URI tmpURI = NextURI; + // Do not allow a redirection to switch protocol + if (tmpURI.Access == "http") + return TRY_AGAIN_OR_REDIRECT; } /* else pass through for error message */ } -- cgit v1.2.3-70-g09d2 From 046e104e1371584251ad2568a11090fe4ed9a42e Mon Sep 17 00:00:00 2001 From: Raphael Geissert Date: Mon, 14 May 2012 18:27:37 +0200 Subject: * methods/mirror.cc: - generate an equal sign also for the first arch (Closes: #669142) --- debian/changelog | 3 +++ methods/mirror.cc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'methods') diff --git a/debian/changelog b/debian/changelog index 937bde918..88057d531 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,9 @@ apt (0.9.4) UNRELEASED; urgency=low in the method the redirection occured in (Closes: #668111) * methods/http.cc: - forbid redirects to change protocol + * methods/mirror.cc: + - generate an equal sign also for the first arch (Closes: #669142) + -- David Kalnischkies Fri, 11 May 2012 23:26:59 +0200 diff --git a/methods/mirror.cc b/methods/mirror.cc index eb6d97425..d6c5ba955 100644 --- a/methods/mirror.cc +++ b/methods/mirror.cc @@ -150,7 +150,7 @@ bool MirrorMethod::DownloadMirrorFile(string mirror_uri_str) for (std::vector::const_iterator I = vec.begin(); I != vec.end(); ++I) if (I == vec.begin()) - fetch += "?arch" + (*I); + fetch += "?arch=" + (*I); else fetch += "&arch=" + (*I); -- cgit v1.2.3-70-g09d2 From 8221431757c775ee875a061b184b5f6f2330f928 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 15 May 2012 00:12:21 +0200 Subject: * methods/http.cc: - after many years of pointless discussions disable http/1.1 pipelining by default as many webservers and proxies seem to be unable to conform to specification must's (rfc2616 section 8.1.2.2) (LP: #996151) --- debian/changelog | 4 ++++ doc/apt.conf.5.xml | 13 ++++++------- methods/http.cc | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'methods') diff --git a/debian/changelog b/debian/changelog index 88057d531..dd8ca72cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,10 @@ apt (0.9.4) UNRELEASED; urgency=low [ David Kalnischkies ] + * methods/http.cc: + - after many years of pointless discussions disable http/1.1 pipelining + by default as many webservers and proxies seem to be unable to conform + to specification must's (rfc2616 section 8.1.2.2) (LP: #996151) * apt-pkg/pkgcachegen.cc: - make IsDuplicatedDescription static so that it is really private as we don't need a symbol for it as it is not in a header diff --git a/doc/apt.conf.5.xml b/doc/apt.conf.5.xml index c2220b1bf..2f95c1e52 100644 --- a/doc/apt.conf.5.xml +++ b/doc/apt.conf.5.xml @@ -340,13 +340,12 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";}; The option timeout sets the timeout timer used by the method, this applies to all things including connection timeout and data timeout. - One setting is provided to control the pipeline depth in cases where the - remote server is not RFC conforming or buggy (such as Squid 2.0.2). - Acquire::http::Pipeline-Depth can be a value from 0 to 5 - indicating how many outstanding requests APT should send. A value of - zero MUST be specified if the remote host does not properly linger - on TCP connections - otherwise data corruption will occur. Hosts which - require this are in violation of RFC 2068. + The setting Acquire::http::Pipeline-Depth can be used to + enabled HTTP pipeling (RFC 2616 section 8.1.2.2) which can be beneficial e.g. on + high-latency connections. It specifies how many requests are send in a pipeline. + Previous APT versions had a default of 10 for this setting, but the default value + is now 0 (= disabled) to avoid problems with the ever-growing amount of webservers + and proxies which choose to not conform to the HTTP/1.1 specification. The used bandwidth can be limited with Acquire::http::Dl-Limit which accepts integer values in kilobyte. The default value is 0 which deactivates diff --git a/methods/http.cc b/methods/http.cc index bb02176e9..c8e6f1b7b 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -61,7 +61,7 @@ using namespace std; string HttpMethod::FailFile; int HttpMethod::FailFd = -1; time_t HttpMethod::FailTime = 0; -unsigned long PipelineDepth = 10; +unsigned long PipelineDepth = 0; unsigned long TimeOut = 120; bool AllowRedirect = false; bool Debug = false; -- cgit v1.2.3-70-g09d2 From 335e2c82afc5ddb305c9e36fac17a024d7dc9c3f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 17 May 2012 14:21:13 +0200 Subject: add spaces around PACKAGE_VERSION to fix FTBFS with -std=c++11 --- debian/changelog | 4 +--- methods/http.cc | 2 +- methods/https.cc | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) (limited to 'methods') diff --git a/debian/changelog b/debian/changelog index 64af5bf60..bcc29eb86 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ apt (0.9.4) UNRELEASED; urgency=low - after many years of pointless discussions disable http/1.1 pipelining by default as many webservers and proxies seem to be unable to conform to specification must's (rfc2616 section 8.1.2.2) (LP: #996151) + - add spaces around PACKAGE_VERSION to fix FTBFS with -std=c++11 * apt-pkg/pkgcachegen.cc: - make IsDuplicatedDescription static so that it is really private as we don't need a symbol for it as it is not in a header @@ -42,9 +43,6 @@ apt (0.9.4) UNRELEASED; urgency=low * apt-pkg/algorithms.cc: - fix memory leak of Flags in pkgSimulate by a proper destructor - [ David Kalnischkies ] - * - -- David Kalnischkies Fri, 11 May 2012 23:26:59 +0200 apt (0.9.3) unstable; urgency=low diff --git a/methods/http.cc b/methods/http.cc index c8e6f1b7b..acf25a42a 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -758,7 +758,7 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) Base64Encode(Uri.User + ":" + Uri.Password) + "\r\n"; } Req += "User-Agent: " + _config->Find("Acquire::http::User-Agent", - "Debian APT-HTTP/1.3 ("PACKAGE_VERSION")") + "\r\n\r\n"; + "Debian APT-HTTP/1.3 (" PACKAGE_VERSION ")") + "\r\n\r\n"; if (Debug == true) cerr << Req << endl; diff --git a/methods/https.cc b/methods/https.cc index fac7ba790..c1a49ba60 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -219,7 +219,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm) curl_easy_setopt(curl, CURLOPT_USERAGENT, _config->Find("Acquire::https::User-Agent", _config->Find("Acquire::http::User-Agent", - "Debian APT-CURL/1.0 ("PACKAGE_VERSION")").c_str()).c_str()); + "Debian APT-CURL/1.0 (" PACKAGE_VERSION ")").c_str()).c_str()); // set timeout int const timeout = _config->FindI("Acquire::https::Timeout", -- cgit v1.2.3-70-g09d2