diff --git a/src/AnnounceList.cc b/src/AnnounceList.cc index c60dcda6..caf4259a 100644 --- a/src/AnnounceList.cc +++ b/src/AnnounceList.cc @@ -109,10 +109,15 @@ void AnnounceList::announceSuccess() if (currentTrackerInitialized_) { (*currentTier_)->nextEvent(); auto url = *currentTracker_; - (*currentTier_)->urls.erase(currentTracker_); + currentTracker_ = (*currentTier_)->urls.erase(currentTracker_); (*currentTier_)->urls.push_front(std::move(url)); - currentTier_ = std::begin(tiers_); - currentTracker_ = std::begin((*currentTier_)->urls); + if (currentTracker_ == std::end((*currentTier_)->urls)) { + ++currentTier_; + if (currentTier_ == std::end(tiers_)) { + currentTier_ = std::begin(tiers_); + } + currentTracker_ = std::begin((*currentTier_)->urls); + } } } diff --git a/src/AnnounceList.h b/src/AnnounceList.h index dd4e8f7e..f53bba99 100644 --- a/src/AnnounceList.h +++ b/src/AnnounceList.h @@ -95,8 +95,9 @@ public: /** * Removes current announce URL from its group and inserts it before the * first element of the group. - * The internal announce group pointer points to the first element of the - * first group after this call. + * The internal announce group pointer points to the next element. + * If the current URL is the last element of its group, then the first + * element of the next group is pointed. */ void announceSuccess();