Skip to content

Commit

Permalink
Merge pull request #10335 from gyuho/release-3.3-patch
Browse files Browse the repository at this point in the history
[Cherry pick 3.3] grpcproxy: fix memory leak
  • Loading branch information
gyuho committed Dec 18, 2018
2 parents 6f250f9 + 59cc0f9 commit e6b2f00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sudo: required
services: docker

go:
- 1.10.4
- 1.10.7

notifications:
on_success: never
Expand All @@ -23,7 +23,7 @@ env:
matrix:
fast_finish: true
allow_failures:
- go: 1.10.4
- go: 1.10.7
env: TARGET=linux-386-unit
exclude:
- go: tip
Expand Down
11 changes: 7 additions & 4 deletions proxy/grpcproxy/cache/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@ func (c *cache) Add(req *pb.RangeRequest, resp *pb.RangeResponse) {
iv = c.cachedRanges.Find(ivl)

if iv == nil {
c.cachedRanges.Insert(ivl, []string{key})
val := map[string]struct{}{key: {}}
c.cachedRanges.Insert(ivl, val)
} else {
iv.Val = append(iv.Val.([]string), key)
val := iv.Val.(map[string]struct{})
val[key] = struct{}{}
iv.Val = val
}
}

Expand Down Expand Up @@ -141,8 +144,8 @@ func (c *cache) Invalidate(key, endkey []byte) {

ivs = c.cachedRanges.Stab(ivl)
for _, iv := range ivs {
keys := iv.Val.([]string)
for _, key := range keys {
keys := iv.Val.(map[string]struct{})
for key := range keys {
c.lru.Remove(key)
}
}
Expand Down

0 comments on commit e6b2f00

Please sign in to comment.