middleware/cache: fix race (#757)
While adding a parallel performance benchmark I stumbled on a race condition (another reason to add performance benchmarks!), so this PR makes sure the msg is created in a race free manor and adds the parallel benchmark.
This commit is contained in:
parent
ea90702bfc
commit
da5880a273
4 changed files with 67 additions and 27 deletions
1
middleware/cache/handler.go
vendored
1
middleware/cache/handler.go
vendored
|
@ -29,6 +29,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
|||
i, ttl := c.get(now, qname, qtype, do)
|
||||
if i != nil && ttl > 0 {
|
||||
resp := i.toMsg(r)
|
||||
|
||||
state.SizeAndDo(resp)
|
||||
resp, _ = state.Scrub(resp)
|
||||
w.WriteMsg(resp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue