Repository navigation
happy eyeballs: bound work from many duplicate/failing addresses - #22897
Closed
MegaManSec wants to merge 2 commits into
Closed
MegaManSec wants to merge 2 commits into
MegaManSec wants to merge 2 commits into
Conversation
A DNS response with many duplicate addresses that fail to connect synchronously could stall a transfer: failed attempts were never pruned from the running list (cf_ip_ballers_prune only removes still-ongoing ones), so every new address triggered a full rescan and an O(n) tail-walk to append, and the connection timeout was only checked after the loop, not during it. Free hard-failed attempts immediately instead of accumulating them, track a tail pointer for O(1) appends, and check the timeout on each iteration. Also cap and deduplicate the addresses converted from a c-ares response, closing off the unbounded input side.
Rename ares_addr_seen() to async_ares_addr_seen() and ARES_MAX_ADDRS to CARES_MAX_ADDRS to match the other statics and defines in the file and to stay out of c-ares' own ares_*/ARES_* namespace. Make the lookup arguments const. Also assert in cf_ip_ballers_run() that the running list is empty once no attempts are left, which is the invariant the last_dead_result reporting relies on.
There was a problem hiding this comment.
🟢 Approval recommended
The bounded address processing and connection-attempt lifecycle changes are internally consistent and preserve list invariants.
Pull request overview
Bounds Happy Eyeballs resource usage for large or failure-heavy address lists.
Changes:
- Deduplicates and caps c-ares results at 256 addresses per response.
- Immediately removes failed connection attempts.
- Adds O(1) list appends and loop-level timeout checks.
File summaries
| File | Description |
|---|---|
lib/vdns/asyn-ares.c |
Caps and deduplicates converted addresses. |
lib/cf-ip-happy.c |
Improves attempt cleanup, timeout handling, and list performance. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
|
Thanks! |
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.
Frees failed connection attempts immediately, adds a tail pointer for O(1) appends, checks the connection timeout on every loop iteration, and caps/deduplicates addresses converted from a c-ares response.