aboutsummaryrefslogtreecommitdiffstats
path: root/cache/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'cache/cache.go')
-rw-r--r--cache/cache.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/cache/cache.go b/cache/cache.go
index f21af5f..5d41bbe 100644
--- a/cache/cache.go
+++ b/cache/cache.go
@@ -152,6 +152,8 @@ func (c *Cache) Reset() {
func (c *Cache) prefetch() bool { return c.client != nil }
func (c *Cache) refresh(key uint64, old *dns.Msg) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
q := old.Question[0]
msg := dns.Msg{}
msg.SetQuestion(q.Name, q.Qtype)
@@ -159,8 +161,6 @@ func (c *Cache) refresh(key uint64, old *dns.Msg) {
if err != nil {
return // Retry on next request
}
- c.mu.Lock()
- defer c.mu.Unlock()
if !c.set(key, r) {
c.evict(key)
}