> On 28 Nov 2020, at 10:36 pm, b.ca...@pobox.com <b.cand...@pobox.com> wrote: > > Unless you timestamp those log lines, I don't see any evidence that the DNS > query is done when the godoc server shuts down. Could it not just be that > after the 2 second sleep, when it's time to make a new connection, it finds > that the pool is empty so has to do a lookup to establish a new connection?
Yes, that’s correct. I inferred the same. What I wanted to learn was to see the code where the detection that the remote server had gone/connection had gone bad and it was removed from the pool. > > I've tested this myself, using your code and apache running on the local > server. > > $ go run httpclient.go http://localhost:80/ > DNS Start Info: {Host:localhost} > DNS Done Info: {Addrs:[{IP:127.0.0.1 Zone:}] Err:<nil> Coalesced:false} > Got Conn: {Conn:0xc000010070 Reused:false WasIdle:false IdleTime:0s} > Put Idle Conn Error: <nil> > Resp protocol: "HTTP/1.1" > Sleeping now > -------- > Got Conn: {Conn:0xc000010070 Reused:true WasIdle:true IdleTime:2.000554686s} > Put Idle Conn Error: <nil> > Resp protocol: "HTTP/1.1" > Sleeping now > << at this point I "systemctl stop apache2" in another terminal >> > << nothing happens until the 2 seconds is up, and then I see: >> > -------- > DNS Start Info: {Host:localhost} > DNS Done Info: {Addrs:[{IP:127.0.0.1 Zone:}] Err:<nil> Coalesced:false} > Got error in making request: Get "http://localhost:80/": dial tcp > 127.0.0.1:80: connect: connection refused > Sleeping now > -------- > DNS Start Info: {Host:localhost} > DNS Done Info: {Addrs:[{IP:127.0.0.1 Zone:}] Err:<nil> Coalesced:false} > Got error in making request: Get "http://localhost:80/": dial tcp > 127.0.0.1:80: connect: connection refused > Sleeping now > ^Csignal: interrupt > > So as far as I can tell, the client tries to re-use the existing connection > from the pool, finds there isn't one (or it's broken), and therefore tries to > establish a new connection - which of course requires a lookup of the > hostname in the URL. That’s correct and matches my understanding which is great. My actual query was to learn how the removal of the broken connection is done. > > Aside: I'd say the trace hooks "DNSStart" and "DNSDone" are somewhat > misnamed, because the hostname resolution isn't necessarily done via DNS - in > both your example and mine it's done via /etc/hosts. But the intention is > clear. Agree. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/bb366eb5-c7df-452a-9549-281543b1b6d4n%40googlegroups.com > > <https://groups.google.com/d/msgid/golang-nuts/bb366eb5-c7df-452a-9549-281543b1b6d4n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/DB179F0B-155F-4E09-9646-6F94F9933B15%40gmail.com.