diff options
author | 2019-07-19 05:19:03 -0400 | |
---|---|---|
committer | 2019-07-19 09:19:03 +0000 | |
commit | 031dfede905143694fb33fb30eba9a1721a77bbc (patch) | |
tree | 3719135f9c889181e78d149b00846449e6e316e9 /go.sum | |
parent | c928dbd754243f55c19c122ccafe7709c041bf4c (diff) | |
download | coredns-031dfede905143694fb33fb30eba9a1721a77bbc.tar.gz coredns-031dfede905143694fb33fb30eba9a1721a77bbc.tar.zst coredns-031dfede905143694fb33fb30eba9a1721a77bbc.zip |
pkg/cache: fix race in Add() and Evict() (#3013)
* pkg/cache: fix race in Add() and Evict()
This fixes a race in Add() when the shard is at max capacity and the key
being added is already stored. Previously, the shard would evict a
random value - when all it needed to do was replace an existing value.
There was a race in how Evict() picked which key to remove, which would
cause concurrent calls to Evict() to remove the same key.
Additionally, this commit removes a lot of the lock contention and a
race around Add() and Evict() by changing them to immediately hold the
write lock. Previously, they would check conditions with the read lock
held and not re-check those conditions once the write lock was acquired
(this is a race).
* pkg/cache: code review comments
* pkg/cache: simplify Add() logic
Diffstat (limited to 'go.sum')
0 files changed, 0 insertions, 0 deletions