Skip to content

Commit

Permalink
Merge branch 'master' into staging-client
Browse files Browse the repository at this point in the history
  • Loading branch information
rod-hynes committed Aug 25, 2022
2 parents c32d6f1 + c5095b1 commit 07849a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion psiphon/common/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ func (r *Resolver) ResolveIP(
if result != nil &&
resolveCtx.Err() == nil &&
atomic.LoadInt64(&inFlight) > 0 &&
(atomic.LoadInt32(&awaitA) != 0 || atomic.LoadInt32(&awaitAAAA) != 0) ||
(atomic.LoadInt32(&awaitA) != 0 || atomic.LoadInt32(&awaitAAAA) != 0) &&
params.AwaitTimeout > 0 {

resetTimer(params.AwaitTimeout)
Expand Down
21 changes: 21 additions & 0 deletions psiphon/common/resolver/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,27 @@ func runTestResolver() error {
return errors.TraceNew("unexpected success")
}

// Test: cancel context while resolving

// This test exercises the additional answers and await cases in
// ResolveIP. The test is timing dependent, and so imperfect, but this
// configuration can reproduce panics in those cases before bugs were
// fixed, where DNS responses need to be received just as the context is
// cancelled.

networkConfig.GetDNSServers = func() []string { return []string{okServer.getAddr()} }
networkID = "networkID-6"

for i := 0; i < 100; i++ {
resolver.cache.Flush()

ctx, cancelFunc := context.WithTimeout(
context.Background(), time.Duration(i%10*20)*time.Microsecond)
defer cancelFunc()

_, _ = resolver.ResolveIP(ctx, networkID, params, exampleDomain)
}

return nil
}

Expand Down

0 comments on commit 07849a1

Please sign in to comment.