net: fix a race in TestLookupContextCancel
If the actual DNS lookup in LookupIPAddr completes quickly enough, it may succeed even if the passed-in Context is already canceled. That would (rarely) cause TestLookupContextCancel to fail due to an unexpectedly-nil error. This change uses the existing testHookLookupIP hook to delay the cancellation until the lookup has started (to try to provoke the code path for which the test was added), and then block the lookup result until LookupIPAddr has noticed it. Fixes #51084 Updates #22724 Change-Id: I331ac61a652ac88f6d4c85bf62466237b76d53ed Reviewed-on: https://go-review.googlesource.com/c/go/+/384237 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by:Ian Lance Taylor <iant@golang.org>
Loading
Please sign in to comment