From e1284a59de37efeedcc998ef61e8466c35b82eb2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 14 May 2012 16:53:43 +0200 Subject: * apt-pkg/acquire-methods.cc: - factor out into private Dequeue() to fix access to deleted pointer --- apt-pkg/acquire-method.cc | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'apt-pkg/acquire-method.cc') diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 2041fd9e9..e6e02bbc5 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -95,12 +95,7 @@ void pkgAcqMethod::Fail(string Err,bool Transient) { std::cout << "400 URI Failure\nURI: " << Queue->Uri << "\n" << "Message: " << Err << " " << IP << "\n"; - // Dequeue - FetchItem *Tmp = Queue; - Queue = Queue->Next; - delete Tmp; - if (Tmp == QueueBack) - QueueBack = Queue; + Dequeue(); } else std::cout << "400 URI Failure\nURI: \nMessage: " << Err << "\n"; @@ -211,13 +206,7 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt) } std::cout << "\n" << std::flush; - - // Dequeue - FetchItem *Tmp = Queue; - Queue = Queue->Next; - delete Tmp; - if (Tmp == QueueBack) - QueueBack = Queue; + Dequeue(); } /*}}}*/ // AcqMethod::MediaFail - Syncronous request for new media /*{{{*/ @@ -465,3 +454,11 @@ void pkgAcqMethod::FetchResult::TakeHashes(Hashes &Hash) SHA512Sum = Hash.SHA512.Result(); } /*}}}*/ +void pkgAcqMethod::Dequeue() { /*{{{*/ + FetchItem const * const Tmp = Queue; + Queue = Queue->Next; + if (Tmp == QueueBack) + QueueBack = Queue; + delete Tmp; +} + /*}}}*/ -- cgit v1.2.3 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 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'apt-pkg/acquire-method.cc') 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 /*{{{*/ -- cgit v1.2.3