mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
grpcproxy: fix memory leak
use set instead of slice as interval value fixes #10326
This commit is contained in:
parent
e57f4f420d
commit
d88f686a91
11
proxy/grpcproxy/cache/store.go
vendored
11
proxy/grpcproxy/cache/store.go
vendored
@ -99,9 +99,12 @@ func (c *cache) Add(req *pb.RangeRequest, resp *pb.RangeResponse) {
|
|||||||
iv = c.cachedRanges.Find(ivl)
|
iv = c.cachedRanges.Find(ivl)
|
||||||
|
|
||||||
if iv == nil {
|
if iv == nil {
|
||||||
c.cachedRanges.Insert(ivl, []string{key})
|
val := map[string]struct{}{key: {}}
|
||||||
|
c.cachedRanges.Insert(ivl, val)
|
||||||
} else {
|
} else {
|
||||||
iv.Val = append(iv.Val.([]string), key)
|
val := iv.Val.(map[string]struct{})
|
||||||
|
val[key] = struct{}{}
|
||||||
|
iv.Val = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,8 +144,8 @@ func (c *cache) Invalidate(key, endkey []byte) {
|
|||||||
|
|
||||||
ivs = c.cachedRanges.Stab(ivl)
|
ivs = c.cachedRanges.Stab(ivl)
|
||||||
for _, iv := range ivs {
|
for _, iv := range ivs {
|
||||||
keys := iv.Val.([]string)
|
keys := iv.Val.(map[string]struct{})
|
||||||
for _, key := range keys {
|
for key := range keys {
|
||||||
c.lru.Remove(key)
|
c.lru.Remove(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user