diff options
| author | Julian Andres Klode <jak@debian.org> | 2022-05-06 16:21:30 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2022-05-06 16:21:30 +0000 |
| commit | 837d145b6b3ff796f8b333d36007628139c8edd2 (patch) | |
| tree | e4e39dca77284490fa4b3616f7468b5eda2ddf7e | |
| parent | 97f16727b50dcaa4810e80d3c16639e0ce6a0958 (diff) | |
| parent | b3a5bbe234d4206b7736bca2ca7f56feaa92f5ff (diff) | |
Merge branch 'mirror-dequeue-fix' into 'main'
Fix mirror method dequeuing incorrect items
See merge request apt-team/apt!236
| -rw-r--r-- | methods/mirror.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/methods/mirror.cc b/methods/mirror.cc index 5a34d8297..787e4c7d5 100644 --- a/methods/mirror.cc +++ b/methods/mirror.cc @@ -145,7 +145,7 @@ void MirrorMethod::RedirectItem(MirrorListInfo const &info, FetchItem *const Itm std::string const path = Itm->Uri.substr(info.baseuri.length()); std::string altMirrors; std::unordered_map<std::string, std::string> fields; - fields.emplace("URI", Queue->Uri); + fields.emplace("URI", Itm->Uri); for (auto curMirror = possMirrors.cbegin(); curMirror != possMirrors.cend(); ++curMirror) { std::string mirror = curMirror->uri; @@ -161,7 +161,19 @@ void MirrorMethod::RedirectItem(MirrorListInfo const &info, FetchItem *const Itm } fields.emplace("Alternate-URIs", altMirrors); SendMessage("103 Redirect", std::move(fields)); - Dequeue(); + + // Remove Itm from the queue, then delete + if (Queue == Itm) + Queue = Itm->Next; + else + { + FetchItem *previous = Queue; + while (previous->Next != Itm) + previous = previous->Next; + + previous->Next = Itm->Next; + } + delete Itm; } /*}}}*/ void MirrorMethod::DealWithPendingItems(std::vector<std::string> const &baseuris, /*{{{*/ |
