]> Cypherpunks repositories - gostls13.git/commit
net: if a DNS lookup times out, forget that it is in flight
authorIan Lance Taylor <iant@golang.org>
Mon, 27 Oct 2014 15:46:18 +0000 (08:46 -0700)
committerIan Lance Taylor <iant@golang.org>
Mon, 27 Oct 2014 15:46:18 +0000 (08:46 -0700)
commit77595e462be07b8229f88cbdf947e320bfc7e639
tree3f60450b01881df43140d21acc8e2825488f2415
parent78082dfa801d484848ac47c04ce3aa9805d2b0c9
net: if a DNS lookup times out, forget that it is in flight

Before this CL, if the system resolver does a very slow DNS
lookup for a particular host, all subsequent requests for that
host will hang waiting for that lookup to complete.  That is
more or less expected when Dial is called with no deadline.
When Dial has a deadline, though, we can accumulate a large
number of goroutines waiting for that slow DNS lookup.  Try to
avoid this problem by restarting the DNS lookup when it is
redone after a deadline is passed.

This CL also avoids creating an extra goroutine purely to
handle the deadline.

No test because we would have to simulate a slow DNS lookup
followed by a fast DNS lookup.

Fixes #8602.

LGTM=bradfitz
R=bradfitz, mikioh.mikioh
CC=golang-codereviews, r, rsc
https://golang.org/cl/154610044
src/net/lookup.go
src/net/singleflight.go