aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/handler.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2020-12-11 17:49:47 +0100
committerGravatar GitHub <noreply@github.com> 2020-12-11 08:49:47 -0800
commit108d26ebea14599fe4acb7dc5e1d2c87a7a01d51 (patch)
tree9da5bf8d0a017bb5b6201a17666ee093381ebf75 /plugin/cache/handler.go
parent9db3a2a72e1b1d24e88ba721d44a24eb01f10a88 (diff)
downloadcoredns-108d26ebea14599fe4acb7dc5e1d2c87a7a01d51.tar.gz
coredns-108d26ebea14599fe4acb7dc5e1d2c87a7a01d51.tar.zst
coredns-108d26ebea14599fe4acb7dc5e1d2c87a7a01d51.zip
Move .LocalAddr() out of goroutine (#4281)
I don't have theory why this panics, but concurrency has something to do with it, so get the address before we call the goroutine. See #4271 Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/cache/handler.go')
-rw-r--r--plugin/cache/handler.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/plugin/cache/handler.go b/plugin/cache/handler.go
index 406ece8e6..350ec0bb0 100644
--- a/plugin/cache/handler.go
+++ b/plugin/cache/handler.go
@@ -49,11 +49,12 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
servedStale.WithLabelValues(server).Inc()
// Adjust the time to get a 0 TTL in the reply built from a stale item.
now = now.Add(time.Duration(ttl) * time.Second)
+ addr := w.LocalAddr() // See https://github.com/coredns/coredns/issues/4271, unclear how, but pull this out of the goroutine, and get the address here.
go func() {
if !do {
setDo(rc)
}
- crr := &ResponseWriter{Cache: c, state: state, server: server, prefetch: true, remoteAddr: w.LocalAddr(), do: do}
+ crr := &ResponseWriter{Cache: c, state: state, server: server, prefetch: true, remoteAddr: addr, do: do}
plugin.NextOrFailure(c.Name(), c.Next, ctx, crr, rc)
}()
}