From 9e22c99efba779cf68a32be2c7c861ac11e841cd Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 15 Oct 2026 16:03:15 +0000 Subject: [PATCH] resolver: drop the unused timeout multiplier and the comment claiming it (closes #296) The resolver declared timeoutMultiplier and passed each try's number to exchangeWithTimeout, which threw it away with a comment saying the client config grew the timeout. Nothing did: every try waits the same 2-second queryTimeoutDuration. The constant goes, and exchangeWithTimeout is folded into its one caller, tryExchange, whose comment now says the timeout is fixed. Behaviour is unchanged. Model: opus-5-5 --- TODO.md | 3 +++ internal/resolver/iterative.go | 22 ++++------------------ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/TODO.md b/TODO.md index ba34bd0..9375cbd 100644 --- a/TODO.md +++ b/TODO.md @@ -19,6 +19,9 @@ milestone: https://git.eeqj.de/sneak/dnswatcher/milestone/7 # Completed Steps +- 2026-10-15: the resolver no longer says its query timeout grows on each try; + every try waits the same 2 seconds, and the unused `timeoutMultiplier` is gone + (closes #296). - 2026-10-15: `TESTING.md` Constraints give the resolver's 2-second query timeout and second try, say a zone's servers are asked one at a time in a random order, give the 60-second cap and 20-second target for `make test`, and diff --git a/internal/resolver/iterative.go b/internal/resolver/iterative.go index 7e5d0e4..4d495f7 100644 --- a/internal/resolver/iterative.go +++ b/internal/resolver/iterative.go @@ -19,7 +19,6 @@ const ( queryTimeoutDuration = 2 * time.Second maxRetries = 2 maxDelegation = 20 - timeoutMultiplier = 2 // maxLookupDepth is how many lookups of nameserver addresses may be // under way one inside another. Looking up a nameserver's address @@ -62,19 +61,8 @@ func checkCtx(ctx context.Context) error { return nil } -func (r *Resolver) exchangeWithTimeout( - ctx context.Context, - msg *dns.Msg, - addr string, - attempt int, -) (*dns.Msg, error) { - _ = attempt // timeout escalation handled by client config - - resp, _, err := r.client.ExchangeContext(ctx, msg, addr) - - return resp, err -} - +// tryExchange sends msg to addr over UDP, up to maxRetries times, until +// a reply comes. Every try waits the same queryTimeoutDuration. func (r *Resolver) tryExchange( ctx context.Context, msg *dns.Msg, @@ -84,14 +72,12 @@ func (r *Resolver) tryExchange( var err error - for attempt := range maxRetries { + for range maxRetries { if checkCtx(ctx) != nil { return nil, ErrContextCanceled } - resp, err = r.exchangeWithTimeout( - ctx, msg, addr, attempt, - ) + resp, _, err = r.client.ExchangeContext(ctx, msg, addr) if err == nil { break }