Repository navigation
arg: reuse hostname addresses across port lists - #421
Merged
Merged
Conversation
A host name that resolves to both IPv6 and IPv4 is searched for every port in a comma-separated list. The fix for that in #416 re-resolved the name for each port because gethostbyname2() returns static storage that the IPv4 fallback overwrites. Copy the IPv6 and IPv4 address lists into private storage and reuse them for every port. This keeps the per-port family search while reducing the resolver calls from about 2N to 2 for N ports. The cache also avoids the stale n.a / NULL hostent path for names that resolve only to IPv6, and MAXNWAD is raised so a dual-stack name with 100 comma-separated ports still fits the address chain.
Move the port-list family regression out of case-23 into its own case-25. case-23 is reported as SKIP on CI when the configured host name has only one address, which hid the new test's PASS. The new case uses the loopback addresses returned by getaddrinfo() instead of hard-coded ones, reports failures with FAIL:/sys.exit(1) instead of an assert, and skips only if a dual-family localhost is unavailable. Make case-23 count addresses across families and fall back to localhost, so it runs on systems whose host name has a single address.
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.
Follow-up to #416.
Changes
-i@host:port1,port2,.... For N ports this reduces resolver calls from about 2N to 2. The cache also avoids the stalen.a/NULL hostent path for names that resolve only to IPv6.MAXNWADfrom 100 to 200 so a dual-stack name with 100 comma-separated ports still fits the address chain (each port now needs an entry per family).tests/case-23-multi-address-hostname.bashintotests/case-25-hostname-port-families.bash, so its PASS/SKIP state is visible. case-23 was reported as SKIP on CI when the configured host name had a single address, hiding the new test.getaddrinfo()instead of hard-coded127.0.0.1/::1, use explicitFAIL:/sys.exit(1)instead ofassert, and skip only when a dual-family localhost is genuinely unavailable.Testing
arg.c(found={'3'}, expected={'3','4'}) and passes with this branch.-i4/-i6prefixes, separate-i4/-i6, repeated-i, and unknown hosts.Addresses the review follow-ups from #416.