aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Wu Shuang <qnnnnez@live.com> 2021-10-24 11:17:47 +0800
committerGravatar GitHub <noreply@github.com> 2021-10-23 20:17:47 -0700
commit4a7565ff63730639a6607dbbad0410fd85a66049 (patch)
tree6b8c06b89ad4fd9f292023c7ad450a624a2f324e
parent2a3f7c93d68dc120420a6ab395b111ed7173436c (diff)
downloadcoredns-4a7565ff63730639a6607dbbad0410fd85a66049.tar.gz
coredns-4a7565ff63730639a6607dbbad0410fd85a66049.tar.zst
coredns-4a7565ff63730639a6607dbbad0410fd85a66049.zip
plugin/pkg/cache: fix data race (#4932)
-rw-r--r--plugin/pkg/cache/cache.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/plugin/pkg/cache/cache.go b/plugin/pkg/cache/cache.go
index 19b35e870..5105c4f7d 100644
--- a/plugin/pkg/cache/cache.go
+++ b/plugin/pkg/cache/cache.go
@@ -136,8 +136,8 @@ func (s *shard) Len() int {
// Walk walks the shard for each element the function f is executed while holding a write lock.
func (s *shard) Walk(f func(map[uint64]interface{}, uint64) bool) {
- items := make([]uint64, len(s.items))
s.RLock()
+ items := make([]uint64, len(s.items))
i := 0
for k := range s.items {
items[i] = k