Fix index issue with records in HostDBRecord::select_best_srv#13132
Open
cmcfarlen wants to merge 2 commits intoapache:masterfrom
Open
Fix index issue with records in HostDBRecord::select_best_srv#13132cmcfarlen wants to merge 2 commits intoapache:masterfrom
cmcfarlen wants to merge 2 commits intoapache:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a subtle selection bug in HostDBRecord::select_best_srv where a stale index variable from a prior index-based loop was still being used after converting the loop to range-based iteration, potentially causing incorrect skipping of SRV targets.
Changes:
- Remove the unused / stale loop index variable and stop indexing
rr[i]inside the range-based loop. - Use the range-loop reference (
target) consistently foris_down()checks. - Re-scope the
iindex to the weighted-selection loop where it is actually needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This came up in a copilot review of a fix unrelated to this issue so I created this separate PR to address this.
It seems the loop structure at some point looped over an index, but was changed to a range based loop, neglecting to change one aspect. But it was not noticed because the index variable is declared before the loop.
The issue is the is_down is always checked on the first target, so could skip up targets or use down targets depending.